主题
LinkEffectUnit
概览
| 字段 | 值 |
|---|---|
| Kind | Unit · 单位 Unit |
| Realm | common |
继承关系
- Unit(5 属性 / 28 函数 / 6 事件)
- EffectUnit(19 属性 / 14 函数)
- [LinkEffectUnit](3 属性)
- EffectUnit(19 属性 / 14 函数)
继承成员
2 个来源 / 24 属性 / 42 函数 / 6 事件
- 来自 EffectUnit(19 属性 / 14 函数)
- 属性:
Position、Rotation、Scale、EffectId、DiffuseColor、ColorStrength、BlendFactor、EnableColor、PlayRate、Visible、Volume、Duration、IsMute、EffectBindData、EffectEndBindData、EnemyEffectEnable、EnemyEffectId、AsyncLoad、ForceLoop - 函数:
SetRate、SetScale、SetVisible、SetRotation、SetPosition、RemoveSound、SetColor、SetBindData、StartposAttach、EndposAttach、SetDuration、MoveTo、SetMute、Restart
- 属性:
- 来自 Unit(5 属性 / 28 函数 / 6 事件)
- 属性:
AssetId、Name、Desc、Parent、Tags - 函数:
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、HasTag、AddTag、RemoveTag - 事件:
ChildAdded、ChildRemoved、DescendantAdded、DescendantRemoving、AncestryChanged、Destroying
- 属性:
连线特效单位用于在场景中生成一条从起点连向终点的特效连线,常用来表现光束、锁链、牵引或连接类视觉反馈。它通过 EndPosition 指定终点的世界坐标,也可以开启 UseEndBindUnit 并把 EndBindUnit 指向另一个单位,让连线终点跟随该单位移动。该类型只提供终点相关的三个属性,起点与播放等表现由创建时的配置决定。
适用场景
常见于技能命中时在施法者与目标之间拉出一条光束,或把终点绑定到被牵引的单位上,使连线随着目标移动而实时改变方向。
使用要点
先通过 game:CreateUnit("LinkEffectUnit", {...}) 或 World:CreateUnit("LinkEffectUnit", {...}) 创建实例,并在创建配置中写入 EndPosition;若需要终点跟随某个单位,则把 UseEndBindUnit 置为真,并把 EndBindUnit 赋为该单位。实例创建完成后可直接读取或改写 EndPosition 来调整固定终点,也可切换 EndBindUnit 更换跟随目标。
注意事项
该单位必须通过创建接口生成,不能直接构造,也不要在清单之外寻找其它创建方式。使用绑定终点时,EndBindUnit 需要在场景中处于有效状态,且应与 UseEndBindUnit 配合使用,否则连线终点仍取 EndPosition。属性只在实例有效期内可读写,单位销毁后不应再访问其终点属性。
代码示例
创建 LinkEffectUnit 实例
lua
-- @runtime client
local World = game:GetService('World')
local linkEffectUnit = World:CreateUnit('LinkEffectUnit', {})
if linkEffectUnit == nil then return end
print('LinkEffectUnit 已创建:', linkEffectUnit.Name)属性 (3)
| Name | 类型 | 默认值 | 说明 |
|---|---|---|---|
EndPosition | Vector3 | [0, 0, 0] | LinkEffectUnit 的终点坐标属性,属性类型为 Vector3,可读写。它用三维坐标描述连线特效的终点位置。 |
UseEndBindUnit | Bool | false | 终点绑定单位开关,用于控制链接特效是否采用指定的单位作为终点。 |
EndBindUnit | Unit | - | EndBindUnit 是 LinkEffectUnit 的终点绑定单位属性,用于指定连接特效终点所跟随的 Unit 实例。该属性可读写,类型为 Unit,默认值为空。 |
