主题
GradientSky
概览
| 字段 | 值 |
|---|---|
| Kind | Unit · 单位 Unit |
| Realm | common |
继承关系
继承成员
2 个来源 / 5 属性 / 25 函数 / 6 事件
- 来自 BaseSky(1 属性)
- 来自 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
- 属性:
渐变天空用于在场景中创建双色渐变背景,通过起始颜色和结束颜色定义天空色调,并支持调整渐变方向、过渡位置和柔和度。它继承自基础天空类型,可受雾效影响,适合营造不同的环境氛围。
适用场景
在需要自定义天空外观的场景中,通过创建 GradientSky 实例并设置其颜色和方向属性,快速实现水平或垂直渐变天空效果,常用于渲染测试或环境美术调整。
使用要点
通过 World:CreateUnit("GradientSky", values) 创建实例,设置 StartColor、EndColor、Direction、Center 与 Softness,再将 Parent 设为 LightingService。
注意事项
实例必须挂载到 LightingService 下才会显示;Direction 使用 Enums.GradientSkyDirection,AffectedByFog 控制是否受雾效影响。
代码示例
创建并配置双色渐变天空
lua
-- @runtime client
local World = game:GetService("World")
local LightingService = game:GetService("LightingService")
local sky = World:CreateUnit("GradientSky", {
StartColor = Color.New(255, 120, 170, 255),
EndColor = Color.New(100, 190, 255, 255),
Direction = Enums.GradientSkyDirection.Y,
Center = 0.5,
Softness = 0.35,
})
sky.Parent = LightingService属性 (5)
| Name | 类型 | 默认值 | 说明 |
|---|---|---|---|
StartColor | Color | Color.New(255, 171, 209, 255) | 渐变天空的起始颜色,与 EndColor 共同定义天空的渐变效果。 |
EndColor | Color | Color.New(127, 215, 255, 255) | 渐变天空的结束颜色,与 StartColor 共同定义天空的渐变效果。 |
Direction | GradientSkyDirection | Enums.GradientSkyDirection.X | 指定渐变方向,可选值为 Enums.GradientSkyDirection.X 或 Enums.GradientSkyDirection.Y。 |
Center | Float | 0.5 | 控制渐变过渡中心的位置,取值范围通常为 0 到 1。 |
Softness | Float | 1.0 | 控制渐变过渡的柔和程度,取值范围通常为 0 到 1。 |
