主题
EUILayout
概览
| 字段 | 值 |
|---|---|
| Kind | Unit · 单位 Unit |
| Realm | common |
继承关系
- Unit(4 属性 / 25 函数 / 6 事件)
- EUINodeBase(34 属性 / 8 函数 / 4 事件)
- [EUILayout](1 属性)
- 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
- 属性:
EUILayout 是一个 UI 布局容器节点,用于承载和管理其他 UI 元素。它支持开启裁切功能,当子节点超出自身边界时可将其隐藏,适合构建列表、滚动区域或需要限制显示范围的界面。
适用场景
在制作背包、聊天记录或设置面板等界面时,将 EUILayout 作为父容器,放入多个子 UI 节点,并开启 ClippingEnabled 属性来裁切超出部分,实现整齐的列表或区域显示。
使用要点
通过 game:GetService("Players").LocalPlayer.PlayerGui.EuiManager:GetRootNode() 获取根节点,再使用 game:GetService("World"):CreateUnit("EUILayout", { Parent = 根节点, Position = Vector2.New(0, 0), Size = Vector2.New(100, 40) }) 创建实例。然后设置 ClippingEnabled 属性为 true 以启用裁切,并将其他 UI 节点作为子节点添加进去。
注意事项
实例必须通过 World:CreateUnit 创建并指定 Parent,不能直接调用 EUILayout.New()。裁切功能依赖 ClippingEnabled 属性,默认可能为关闭状态,需要显式开启。作为容器节点,其子节点的位置和大小是相对于 EUILayout 自身坐标系计算的。
代码示例
创建布局容器并开启裁切
lua
-- @runtime client
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()
local panel = World:CreateUnit("EUILayout", {
Parent = rootNode,
Position = Vector2.New(0, 0),
Size = Vector2.New(100, 40),
})
panel.ClippingEnabled = true属性 (1)
| Name | 类型 | 默认值 | 说明 |
|---|---|---|---|
ClippingEnabled | Bool | false | 控制是否对超出布局区域的内容进行裁剪。 |
