主题
EUILayout
概览
| 字段 | 值 |
|---|---|
| Kind | Unit · 单位 Unit |
| Realm | common |
继承关系
- Unit(4 属性 / 25 函数 / 6 事件)
- EUINodeBase(35 属性 / 12 函数 / 4 事件)
- [EUILayout](1 属性)
- EUINodeBase(35 属性 / 12 函数 / 4 事件)
继承成员
2 个来源 / 39 属性 / 36 函数 / 10 事件
- 来自 EUINodeBase(35 属性 / 12 函数 / 4 事件)
- 属性:
Visible、Position、Anchor、FlippedX、FlippedY、Size、Rotation、Opacity、TouchBeginAudio、TouchEndAudio、TouchClickAudio、TouchbeginEvent、ClickEvent、TouchendEvent、LongtouchEvent、ShowEvent、HideEvent、TouchEnabled、TouchDragEnabled、SwallowTouchEnabled、TopAdaptMode、TopAdaption、BottomAdaptMode、BottomAdaption、LeftAdaptMode、LeftAdaption、RightAdaptMode、RightAdaption、AnchorXAdaptMode、AnchorXAdaption、AnchorYAdaptMode、AnchorYAdaption、LocalZOrder、LayoutOrder、Scale - 函数:
RemoveFromParent、GetFullPath、TweenPosition、TweenSize、TweenSizeAndPosition、TweenOpacity、Retain、Release、GetWorldPosition、ConvertToWorldPosition、ConvertToLocalPosition、HitTest - 事件:
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、GetDebugId - 事件:
ChildAdded、ChildRemoved、DescendantAdded、DescendantRemoving、AncestryChanged、Destroying
- 属性:
EUILayout 是界面层级中的容器节点单位,用于承载并组织其它界面节点的位置与尺寸,自身不绘制可见内容。它提供 ClippingEnabled 开关,用于决定超出容器边界的内容是否被裁切,从而让界面在有限区域内保持整洁有序。
适用场景
常用于搭建界面时先创建一个父容器,再把背景、图标、文本等子节点挂到容器内部统一摆放,例如先铺满全屏背景,再创建居中的父容器来放置一组相互重叠的控件。
使用要点
先通过 game:GetService("Players").LocalPlayer.PlayerGui.EuiManager:GetRootNode() 获取根节点作为父级,再调用 game:GetService("World"):CreateUnit("EUILayout", { Parent = parent, Position = Vector2.New(0, 0), Size = Vector2.New(100, 40) }) 创建容器。创建完成后可按需设置 ClippingEnabled,控制子节点内容是否被裁切。
注意事项
EUILayout 通过 game:CreateUnit 或 World:CreateUnit 创建,并把 Parent 设置为有效的界面节点。它公开 ClippingEnabled 属性来控制子节点超出容器范围时是否裁剪;Meta 将该属性标记为 editable=false,表示编辑器面板不可直接编辑。
代码示例
创建布局容器并开启裁切
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),
})
if panel == nil then return end
panel.ClippingEnabled = true属性 (1)
| Name | 类型 | 默认值 | 说明 |
|---|---|---|---|
ClippingEnabled | Bool | false | 控制超出容器区域的子节点内容是否被裁剪,默认 false。Meta 标记 editable=false,表示编辑器面板不可直接编辑。 |
