主题
LinkEffectUnit
概览
| 字段 | 值 |
|---|---|
| Kind | Unit · 单位 Unit |
| Realm | common |
继承关系
- Unit(4 属性 / 25 函数 / 6 事件)
- EffectUnit(19 属性 / 14 函数)
- [LinkEffectUnit](3 属性)
- EffectUnit(19 属性 / 14 函数)
继承成员
2 个来源 / 23 属性 / 39 函数 / 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(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 的取值,避免终点指向不符合预期。
代码示例
创建 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 | - | LinkEffectUnit 的终点绑定单位属性,属性类型为 Unit,可读写。它用于把连线特效的终点关联到一个具体的单位实例上,作为连线终点的承载对象。 |
