主题
EUINodeBase
EUINodeBase 是编辑器 EUI 节点的基类,节点由 EUIService 的 FindFirstChild、GetDescendants、CreateEUINode 等方法返回。
概览
EUINodeBase 是编辑器 EUI(编辑器 UI 系统)节点的基类,承载节点的名称、可见性、位置、尺寸、锚点、旋转、透明度与同级显示层级等基础呈现属性,以及触摸交互、音效与事件配置、四周约束和锚点约束等通用属性。具体节点由 EUIService 创建或返回,不能直接用 World:CreateUnit 创建。
继承自
Unit;不可实例化,由接口返回
代码示例
通过 EUIService 创建节点并设置基类属性
lua
-- @runtime editor
local euiService = editor:GetService("EUIService")
local wasOpen = euiService:IsInEUIEditMode()
if not wasOpen and not euiService:OpenEUIEditor() then return end
local layer = euiService:CreateEUICanvasLayer("DocumentationNodeBaseLayer")
if layer == nil then
if not wasOpen then euiService:ExitEUIEditor() end
return
end
local node = euiService:CreateEUINode("EUIButton", layer, Vector2.New({x = 20, y = 20}), Vector2.New({x = 160, y = 48}), "DocumentationNodeBaseButton")
if node ~= nil then
node.Visible = true
node.Position = Vector2.New({x = 30, y = 30})
node.Size = Vector2.New({x = 180, y = 56})
print("EUI 节点基类属性:", node.Visible, node.Position, node.Size)
node:Destroy()
end
layer:Destroy()
if not wasOpen then euiService:ExitEUIEditor() end函数
Clone
克隆当前 EUI 节点,生成一个与该节点结构一致的新节点,并返回克隆得到的根节点。
签名:Clone() -> EUINodeBase
返回值 EUINodeBase — 克隆出的根节点;失败时返回 nil
属性
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
Name | String | - | 表示 UI 节点的名称,类型为字符串,可在脚本中读写。 |
Visible | Bool | - | 表示 UI 节点当前是否可见,类型为布尔值,可在脚本中读写。 |
Position | Vector2 | - | 表示 UI 节点的位置,类型为 Vector2,可在脚本中读写。 |
Anchor | Vector2 | - | 表示 UI 节点的锚点,类型为 Vector2,可在脚本中读写。 |
FlippedX | Bool | - | 表示 UI 节点是否进行水平翻转,类型为布尔值,可在脚本中读写。 |
FlippedY | Bool | - | 表示 UI 节点是否进行垂直翻转,类型为布尔值,可在脚本中读写。 |
Size | Vector2 | - | 表示 UI 节点的尺寸,类型为 Vector2,可在脚本中读写。 |
Rotation | Float | - | 表示 UI 节点的旋转角度,类型为浮点数,可在脚本中读写。 |
Opacity | Float | - | 表示 UI 节点的透明度,类型为浮点数,可在脚本中读写。 |
LocalZOrder | Int | - | 表示 UI 节点在同级节点中的显示层级,类型为整数,可在脚本中读写。 |
TouchEnabled | Bool | - | 表示 UI 节点是否响应触摸输入,类型为布尔值,可在脚本中读写。 |
TouchDragEnabled | Bool | - | 表示 UI 节点是否允许拖动,类型为布尔值,可在脚本中读写。 |
TouchBeginAudio | String | - | 表示 UI 节点被按下时使用的音效,类型为字符串,可在脚本中读写。 |
TouchEndAudio | String | - | 表示 UI 节点被抬起时使用的音效,类型为字符串,可在脚本中读写。 |
TouchClickAudio | String | - | 表示 UI 节点被点击时使用的音效,类型为字符串,可在脚本中读写。 |
TouchbeginEvent | String | - | 表示 UI 节点的按下事件名称,类型为字符串,可在脚本中读写。 |
ClickEvent | String | - | 表示 UI 节点的点击事件名称,类型为字符串,可在脚本中读写。 |
TouchendEvent | String | - | 表示 UI 节点的抬起事件名称,类型为字符串,可在脚本中读写。 |
LongtouchEvent | String | - | 表示 UI 节点的长按事件名称,类型为字符串,可在脚本中读写。 |
ShowEvent | String | - | 表示 UI 节点的显示事件名称,类型为字符串,可在脚本中读写。 |
HideEvent | String | - | 表示 UI 节点的隐藏事件名称,类型为字符串,可在脚本中读写。 |
TopAdaptMode | EUIAdaptMode | - | 表示 UI 节点顶部方向的约束模式,取值来自 EUIAdaptMode 枚举,可在脚本中读写。 |
TopAdaption | Float | - | 表示 UI 节点顶部方向的约束值,类型为浮点数,可在脚本中读写。 |
BottomAdaptMode | EUIAdaptMode | - | 表示 UI 节点底部方向的约束模式,取值来自 EUIAdaptMode 枚举,可在脚本中读写。 |
BottomAdaption | Float | - | 表示 UI 节点底部方向的约束值,类型为浮点数,可在脚本中读写。 |
LeftAdaptMode | EUIAdaptMode | - | 表示 UI 节点左侧方向的约束模式,取值来自 EUIAdaptMode 枚举,可在脚本中读写。 |
LeftAdaption | Float | - | 表示 UI 节点左侧方向的约束值,类型为浮点数,可在脚本中读写。 |
RightAdaptMode | EUIAdaptMode | - | 表示 UI 节点右侧方向的约束模式,取值来自 EUIAdaptMode 枚举,可在脚本中读写。 |
RightAdaption | Float | - | 表示 UI 节点右侧方向的约束值,类型为浮点数,可在脚本中读写。 |
AnchorXAdaptMode | EUIAnchorAdaptMode | - | 表示 UI 节点水平方向的约束模式,取值来自 EUIAnchorAdaptMode 枚举,可在脚本中读写。 |
AnchorXAdaption | Float | - | 表示 UI 节点水平方向的约束值,类型为浮点数,可在脚本中读写。 |
AnchorYAdaptMode | EUIAnchorAdaptMode | - | 表示 UI 节点垂直方向的约束模式,取值来自 EUIAnchorAdaptMode 枚举,可在脚本中读写。 |
AnchorYAdaption | Float | - | 表示 UI 节点垂直方向的约束值,类型为浮点数,可在脚本中读写。 |
