主题
PixelateEffect
概览
| 字段 | 值 |
|---|---|
| Kind | Unit · 单位 Unit |
| Realm | common |
继承关系
- Unit(4 属性 / 25 函数 / 6 事件)
- BasePostEffect(1 属性)
- [PixelateEffect](1 属性)
- BasePostEffect(1 属性)
继承成员
2 个来源 / 5 属性 / 25 函数 / 6 事件
- 来自 BasePostEffect(1 属性)
- 属性:
Enabled
- 属性:
- 来自 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
- 属性:
像素化效果是一种后处理特效单元,用于为整个场景或视口添加马赛克般的像素块化视觉风格。通过调整像素块数量属性,可以控制画面的颗粒细腻程度,值越小单个像素块越大,画面越模糊。
适用场景
在需要营造复古游戏、马赛克遮挡或特殊叙事氛围时,开发者会创建一个像素化效果单元,挂载到场景中并调节像素块数量来表现画面失真感。
使用要点
先通过游戏实例的创建单元接口生成一个像素化效果单元,再将其挂载到光照或场景节点下,最后设置像素块数量属性即可生效。如需调整强度,直接修改该属性并等待帧刷新。
注意事项
该单元只能通过创建单元接口实例化,不能直接构造;创建后应挂载到合适的场景父节点下才会对画面生效;像素块数量值越小,马赛克效果越强烈。
代码示例
创建 PixelateEffect 并挂载到光照服务
lua
-- @runtime client
local Lighting = game:GetService('LightingService')
local pixelateEffect = game:CreateUnit('PixelateEffect', {
Enabled = true,
})
pixelateEffect.Parent = Lighting
print('后处理已启用:', pixelateEffect.Enabled)属性 (1)
| Name | 类型 | 默认值 | 说明 |
|---|---|---|---|
PixelCount | Float | 350.0 | 像素化后处理效果中的像素块数量属性,用于控制像素化效果的颗粒密度。 |
