主题
LinkEffectUnit
概览
| 字段 | 值 |
|---|---|
| Kind | Unit · 单位 Unit |
| Realm | common |
继承关系
- Unit(4 属性 / 25 函数 / 6 事件)
- EffectUnit(20 属性 / 13 函数)
- [LinkEffectUnit](3 属性)
- EffectUnit(20 属性 / 13 函数)
继承成员
2 个来源 / 24 属性 / 38 函数 / 6 事件
- 来自 EffectUnit(20 属性 / 13 函数)
- 属性:
Position、Rotation、Scale、EffectId、DiffuseColor、ColorStrength、BlendFactor、EnableColor、PlayRate、Visible、Volume、Duration、IsMute、EffectBindData、EffectEndBindData、AttachEndPos、EnemyEffectEnable、EnemyEffectId、AsyncLoad、ForceLoop - 函数:
SetRate、SetScale、SetVisible、SetRotation、SetPosition、RemoveSound、SetColor、SetBindData、StartposAttach、EndposAttach、SetDuration、MoveTo、SetMute
- 属性:
- 来自 Unit(4 属性 / 25 函数 / 6 事件)
- 属性:
AssetId、Name、Desc、Parent - 函数:
ClearAllChildren、GetChildren、GetDescendants、IsAncestorOf、IsDescendantOf、FindFirstAncestor、FindFirstAncestorWhichIsA、FindFirstAncestorOfClass、FindFirstChild、FindFirstChildWhichIsA、FindFirstChildOfClass、HasChildren、GetChildCount、GetChildAtIndex、SetAttribute、GetAttribute、GetAllProps、Clone、IsA、Destroy、GetPropertyChangedSignal、GetAttributeChangedSignal、FindFromPath、GetFullPath、GetDebugId - 事件:
ChildAdded、ChildRemoved、DescendantAdded、DescendantRemoving、AncestryChanged、Destroying
- 属性:
连线特效单位,用于在两个位置之间渲染一条可视的连线效果。它既可以直接指定终点坐标,也可以将终点绑定到某个场景单位上,从而让连线跟随单位移动,常用于表现激光、牵引线、连接光束等视觉效果。
适用场景
典型场景是在场景中创建一条从起点到目标点的连线特效,例如技能连击指示、单位之间的链接或传送通道效果。
使用要点
通过 game:CreateUnit("LinkEffectUnit", config) 或 World:CreateUnit("LinkEffectUnit", config) 创建实例。若终点固定,可设置 EndPosition 指定终点坐标;若终点需要跟随单位,可将 UseEndBindUnit 设为真并设置 EndBindUnit 为要绑定的单位,连线会自动跟随该单位的位置变化。
注意事项
实例只能通过创建接口获得,不能直接构造。当使用 EndBindUnit 绑定时,需确保绑定的单位在连线存在期间保持有效,单位被销毁后连线可能失效。修改 UseEndBindUnit 后需对应设置 EndPosition 或 EndBindUnit,二者互斥使用。
代码示例
创建 LinkEffectUnit 实例
lua
-- @runtime client
local World = game:GetService('World')
local linkEffectUnit = World:CreateUnit('LinkEffectUnit', {})
print('LinkEffectUnit 已创建:', linkEffectUnit.Name)属性 (3)
| Name | 类型 | 默认值 | 说明 |
|---|---|---|---|
EndPosition | Vector3 | [0, 0, 0] | 终点坐标,用于设置链接特效的终点在世界空间中的位置。 |
UseEndBindUnit | Bool | false | 终点绑定单位开关,用于控制链接特效是否采用指定的单位作为终点。 |
EndBindUnit | Unit | - | 终点绑定单位,用于指定链接特效的终点所绑定的目标单位。 |
