主题
SimpleSpotLight
概览
| 字段 | 值 |
|---|---|
| Kind | Unit · 单位 Unit |
| Realm | common |
继承关系
- Unit(4 属性 / 25 函数 / 6 事件)
- SimpleLight(6 属性)
- [SimpleSpotLight](5 属性)
- SimpleLight(6 属性)
继承成员
2 个来源 / 10 属性 / 25 函数 / 6 事件
- 来自 SimpleLight(6 属性)
- 来自 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
- 属性:
SimpleSpotLight 是锥形装饰性自发光体,可显示光束外观,但不会作为真实聚光灯照亮周围物体。
适用场景
用于舞台光束、探照灯外观或方向性装饰光效。
使用要点
通过 World:CreateUnit("SimpleSpotLight", config) 创建实例,设置 Brightness、Color、Radius 和 InnerAngleFactor 调整锥形外观;需要显示光束特效时设置 ShowSfx=true。
注意事项
当前运行包实测 SimpleSpotLight 即使创建后挂到 WorldUnit 也没有视觉表现,且公开 API 未说明可用的光照挂载结构。以下代码只展示属性形态,不能作为可见效果验收;在引擎补齐挂载契约或可用预设前,不建议用于正式内容。
代码示例
创建锥形光源并切换光束特效
lua
-- @runtime server
local world = game:GetService("World")
local light = world:CreateUnit("SimpleSpotLight", {
Position = Vector3.New(0, 3, -5),
Brightness = 3.0,
Color = Color.New(0, 255, 255, 255),
Radius = 10.0,
InnerAngleFactor = 0.8,
ShowSfx = true,
})
light.ShowSfx = false
print("SimpleSpotLight:", light)属性 (5)
| Name | 类型 | 默认值 | 说明 |
|---|---|---|---|
Brightness | Float | 1.0 | 锥形自发光体自身的亮度。 |
Color | Color | Color.New(255, 255, 255, 255) | 锥形自发光体的颜色。 |
Radius | Float | 5.0 | 控制锥形自发光外观半径的参数,不表示真实照明影响范围。 |
InnerAngleFactor | Float | 0.5 | 控制锥形自发光外观内角大小的因子。 |
ShowSfx | Bool | true | 是否显示锥形光束特效。 |
