Skip to content

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

属性 ​

名称类型默认值说明
NameString-表示 UI 节点的名称,类型为字符串,可在脚本中读写。
VisibleBool-表示 UI 节点当前是否可见,类型为布尔值,可在脚本中读写。
PositionVector2-表示 UI 节点的位置,类型为 Vector2,可在脚本中读写。
AnchorVector2-表示 UI 节点的锚点,类型为 Vector2,可在脚本中读写。
FlippedXBool-表示 UI 节点是否进行水平翻转,类型为布尔值,可在脚本中读写。
FlippedYBool-表示 UI 节点是否进行垂直翻转,类型为布尔值,可在脚本中读写。
SizeVector2-表示 UI 节点的尺寸,类型为 Vector2,可在脚本中读写。
RotationFloat-表示 UI 节点的旋转角度,类型为浮点数,可在脚本中读写。
OpacityFloat-表示 UI 节点的透明度,类型为浮点数,可在脚本中读写。
LocalZOrderInt-表示 UI 节点在同级节点中的显示层级,类型为整数,可在脚本中读写。
TouchEnabledBool-表示 UI 节点是否响应触摸输入,类型为布尔值,可在脚本中读写。
TouchDragEnabledBool-表示 UI 节点是否允许拖动,类型为布尔值,可在脚本中读写。
TouchBeginAudioString-表示 UI 节点被按下时使用的音效,类型为字符串,可在脚本中读写。
TouchEndAudioString-表示 UI 节点被抬起时使用的音效,类型为字符串,可在脚本中读写。
TouchClickAudioString-表示 UI 节点被点击时使用的音效,类型为字符串,可在脚本中读写。
TouchbeginEventString-表示 UI 节点的按下事件名称,类型为字符串,可在脚本中读写。
ClickEventString-表示 UI 节点的点击事件名称,类型为字符串,可在脚本中读写。
TouchendEventString-表示 UI 节点的抬起事件名称,类型为字符串,可在脚本中读写。
LongtouchEventString-表示 UI 节点的长按事件名称,类型为字符串,可在脚本中读写。
ShowEventString-表示 UI 节点的显示事件名称,类型为字符串,可在脚本中读写。
HideEventString-表示 UI 节点的隐藏事件名称,类型为字符串,可在脚本中读写。
TopAdaptModeEUIAdaptMode-表示 UI 节点顶部方向的约束模式,取值来自 EUIAdaptMode 枚举,可在脚本中读写。
TopAdaptionFloat-表示 UI 节点顶部方向的约束值,类型为浮点数,可在脚本中读写。
BottomAdaptModeEUIAdaptMode-表示 UI 节点底部方向的约束模式,取值来自 EUIAdaptMode 枚举,可在脚本中读写。
BottomAdaptionFloat-表示 UI 节点底部方向的约束值,类型为浮点数,可在脚本中读写。
LeftAdaptModeEUIAdaptMode-表示 UI 节点左侧方向的约束模式,取值来自 EUIAdaptMode 枚举,可在脚本中读写。
LeftAdaptionFloat-表示 UI 节点左侧方向的约束值,类型为浮点数,可在脚本中读写。
RightAdaptModeEUIAdaptMode-表示 UI 节点右侧方向的约束模式,取值来自 EUIAdaptMode 枚举,可在脚本中读写。
RightAdaptionFloat-表示 UI 节点右侧方向的约束值,类型为浮点数,可在脚本中读写。
AnchorXAdaptModeEUIAnchorAdaptMode-表示 UI 节点水平方向的约束模式,取值来自 EUIAnchorAdaptMode 枚举,可在脚本中读写。
AnchorXAdaptionFloat-表示 UI 节点水平方向的约束值,类型为浮点数,可在脚本中读写。
AnchorYAdaptModeEUIAnchorAdaptMode-表示 UI 节点垂直方向的约束模式,取值来自 EUIAnchorAdaptMode 枚举,可在脚本中读写。
AnchorYAdaptionFloat-表示 UI 节点垂直方向的约束值,类型为浮点数,可在脚本中读写。