主题
EUIProgressTimer
概览
| 字段 | 值 |
|---|---|
| Kind | Unit · 单位 Unit |
| Realm | common |
继承关系
- Unit(4 属性 / 25 函数 / 6 事件)
- EUINodeBase(34 属性 / 8 函数 / 4 事件)
- [EUIProgressTimer](4 属性)
- EUINodeBase(34 属性 / 8 函数 / 4 事件)
继承成员
2 个来源 / 38 属性 / 33 函数 / 10 事件
- 来自 EUINodeBase(34 属性 / 8 函数 / 4 事件)
- 属性:
Visible、Position、Anchor、FlippedX、FlippedY、Size、Rotation、Opacity、TouchBeginAudio、TouchEndAudio、TouchClickAudio、TouchbeginEvent、ClickEvent、TouchendEvent、LongtouchEvent、ShowEvent、HideEvent、TouchEnabled、SwallowTouchEnabled、TopAdaptMode、TopAdaption、BottomAdaptMode、BottomAdaption、LeftAdaptMode、LeftAdaption、RightAdaptMode、RightAdaption、AnchorXAdaptMode、AnchorXAdaption、AnchorYAdaptMode、AnchorYAdaption、LocalZOrder、LayoutOrder、Scale - 函数:
RemoveFromParent、GetFullPath、TweenPosition、TweenSize、TweenSizeAndPosition、TweenOpacity、Retain、Release - 事件:
OnTouchBegan、OnTouchMoved、OnTouchEnded、OnClicked
- 属性:
- 来自 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
- 属性:
EUIProgressTimer 是进度计时器控件,用于在界面上显示一个可配置颜色、图片和方向的环形进度条。通过设置 Percent 属性(0-100 的浮点数)来控制进度填充比例,并支持动态更换进度条外观。
适用场景
常用于技能冷却、任务倒计时或资源加载等需要可视化进度反馈的场景,将进度条挂载到玩家界面的根节点下即可显示。
使用要点
先通过 game:GetService("Players").LocalPlayer.PlayerGui.EuiManager:GetRootNode() 获取根节点,再使用 World:CreateUnit("EUIProgressTimer", { Parent = root, Position = Vector2.New(0, 0), Size = Vector2.New(100, 40) }) 创建实例。然后设置 Percent 属性更新进度,并可调整 Image、Direction 和 Color 属性定制外观。
注意事项
EUIProgressTimer 是进度计时器控件,通过 World:CreateUnit 创建,并把 Parent 设置为当前玩家 PlayerGui.EuiManager:GetRootNode()(不能自行直接构造,也不能通过 GetService 获取 EUIManager)。Color 类型必须用 0-255 RGBA 四参数构造(如 Color.New(255, 0, 0, 255)),不能用 0-1 归一化值。Percent 的 Meta 契约是 0-100 范围的 Float 百分比(如 60.0 表示 60%),不是 0-1 比例;当前运行包有 GetPercent() 返回字符串、SetPercent(50) 后仍读到 100.0 的反馈,修复前不要把回读值作为业务状态真值,应在脚本中单独保存数值并只把 Percent 赋值用于显示。Direction 是 Int 方向标识,不是 Enums.EasingDirection;Image 的公开类型是 String。
代码示例
创建进度计时器并设置进度
lua
-- @runtime client
local function createProgressTimer(imageUri)
local Players = game:GetService("Players")
local World = game:GetService("World")
local localPlayer = Players.LocalPlayer
if localPlayer == nil then return end
local rootNode = localPlayer.PlayerGui.EuiManager:GetRootNode()
return World:CreateUnit("EUIProgressTimer", {
Parent = rootNode,
Position = Vector2.New(0, 0),
Size = Vector2.New(100, 40),
Image = imageUri,
Percent = 60.0,
Color = Color.New(255, 180, 40, 255),
Direction = 1,
})
end属性 (4)
| Name | 类型 | 默认值 | 说明 |
|---|---|---|---|
Percent | Float | 0.5 | 进度条当前百分比,浮点数类型,表示填充进度。 |
Image | String | official://image/30011 | 进度条使用的图片资源 URI,字符串类型。 |
Direction | Int | 0 (Normal) | 进度条填充方向,整数值表示不同的方向模式。 |
Color | Color | [255, 255, 255, 255] | 进度条填充颜色,使用 Color 类型表示 RGBA 值。 |
