Skip to content

界面模块管理接口 CustomUI

具体函数名及描述如下:

序号函数名函数描述
1SetText(...)设置文本元件内容
2SetTexture(...)设置元件图案纹理
3SetSize(...)设置元件大小
4SetFontSize(...)设置文本元件字体大小
5SetColor(...)设置文本元件颜色
6ShowElement(...)显示元件
7HideElement(...)隐藏元件
8RotateElement(...)旋转元件
9SetAlpha(...)设置透明度
10SetState(...)设置界面状态
11SetPosition(...)设置元件位置
12SetScale(...)设置元件缩放
13GetItemIcon(...)获取道具图标
14GetMonsterObjIcon(...)获取生物图标(对象)
15GetMonsterIcon(...)获取生物图标(类型)
16GetStatusIcon(...)获取状态图标
17GetBlockIcon(...)获取方块图标
18GetRoleIcon(...)获取角色图标
19GetRoleHeadIcon(...)获取角色头像图标
20GetShortcutIcon(...)获取快捷栏图标
21SmoothMoveTo(...)元件平滑移动到指定位置
22SmoothMoveBy(...)元件平滑移动相对距离
23SmoothScaleTo(...)元件平滑缩放到指定尺寸
24SmoothScaleBy(...)元件平滑改变相对宽高
25SmoothScaleByEx(...)元件平滑缩放(扩展)
26SmoothRotateTo(...)元件平滑旋转到指定角度
27SmoothRotateBy(...)元件平滑旋转相对角度
28PlayElementAnim(...)播放元件动画
29StopAnim(...)停止元件动画
30SetLoaderModel(...)设置装载器模型
31SetLoaderModelScale(...)设置装载器模型缩放
32SetLoaderModelDir(...)设置装载器模型方向
33SetLoaderModelPosition(...)设置装载器模型位置
34SetLoaderModelAct(...)设置装载器模型动画
35TurnSliderToPos(...)滑动列表跳转到位置
36SetSliderDir(...)设置滑动列表滑动方式
37SetSliderBarImg(...)设置滑动条图案
38SetRelationPosition(...)设置元件相对位置
39SetRelationSize(...)设置元件相对大小
40CreateElement(...)动态创建元件
41CloneElement(...)克隆元件
42ChangeParent(...)修改元件父元件
43SetProgressBarValue(...)设置进度条值
44GetProgressBarValue(...)获取进度条值
45SetProgressBarResId(...)设置进度条纹理
46SmoothChangeProgress(...)进度条文本平滑变化
47SetSpineAnimID(...)设置Spine动画ID
48SmoothIncreaseProgress(...)进度条文本平滑变化(增减)
49SetFloatDamageTxt(...)设置浮动伤害文本
50GetScreenSize(...)获取屏幕分辨率
51DeleteElement(...)删除UI元件
52SetBeaconMapType(...)设置信标映射类型
53SetBeaconBandPos(...)设置信标位置
54SetBeaconObjId(...)设置信标对象
55SetBeaconOffset(...)设置信标偏移
56SetBeaconClampType(...)设置信标限制范围
57SetBeaconRadius(...)设置信标半径

SetText

  • 参数及类型:
  • 返回值及类型:
  • 该方法的其他说明: 设置指定文本元件的内容,可选带动画效果(打字机等)
  • 具体使用案例如下:
lua
    local isSuccess = CustomUI:SetText(Player:GetHostUin(),"7482986899365911542-22886","7482986899365911542-22886_2", "测试文本")

SetTexture

  • 参数及类型:
  • 返回值及类型:
  • 该方法的其他说明: 设置指定元件的图案纹理(使用纹理资源ID)
  • 具体使用案例如下:
lua
    local isSuccess = CustomUI:SetTexture(Player:GetHostUin(),"7482986899365911542-22886","7482986899365911542-22886_3", "0_10103")

SetSize

  • 参数及类型:
  • 返回值及类型:
  • 该方法的其他说明: 设置指定元件的尺寸(宽高)
  • 具体使用案例如下:
lua
    local isSuccess = CustomUI:SetSize(Player:GetHostUin(),"7482986899365911542-22886","7482986899365911542-22886_3", 200, 100)

SetFontSize

  • 参数及类型:
  • 返回值及类型:
  • 该方法的其他说明: 设置指定文本元件的字体大小
  • 具体使用案例如下:
lua
    local isSuccess = CustomUI:SetFontSize(Player:GetHostUin(),"7482986899365911542-22886","7482986899365911542-22886_2", 20)

SetColor

  • 参数及类型:
  • 返回值及类型:
  • 该方法的其他说明: 设置指定文本元件的颜色
  • 具体使用案例如下:
lua
    local isSuccess = CustomUI:SetColor(Player:GetHostUin(),"7482986899365911542-22886","7482986899365911542-22886_1", "0xf44336")

ShowElement

  • 参数及类型:
  • 返回值及类型:
  • 该方法的其他说明: 显示指定元件,可选播放显示动画
  • 具体使用案例如下:
lua
    local isSuccess = CustomUI:ShowElement(Player:GetHostUin(),"7482986899365911542-22886","7482986899365911542-22886_1")

HideElement

  • 参数及类型:
  • 返回值及类型:
  • 该方法的其他说明: 隐藏指定元件,可选播放隐藏动画
  • 具体使用案例如下:
lua
    local isSuccess = CustomUI:HideElement(Player:GetHostUin(),"7482986899365911542-22886","7482986899365911542-22886_1")

RotateElement

  • 参数及类型:
  • 返回值及类型:
  • 该方法的其他说明: 设置指定元件的旋转角度
  • 具体使用案例如下:
lua
    local isSuccess = CustomUI:RotateElement(Player:GetHostUin(),"7482986899365911542-22886","7482986899365911542-22886_1", 45)

SetAlpha

  • 参数及类型:
  • 返回值及类型:
  • 该方法的其他说明: 设置指定元件的透明度
  • 具体使用案例如下:
lua
    local isSuccess = CustomUI:SetAlpha(Player:GetHostUin(),"7482986899365911542-22886","7482986899365911542-22886_1", 0.5)

SetState

  • 参数及类型:
  • 返回值及类型:
  • 该方法的其他说明: 设置界面状态,可指定缓动类型与过渡时长
  • 具体使用案例如下:
lua
    local isSuccess = CustomUI:SetState(Player:GetHostUin(),"7482986899365911542-22886","7482986899365911542-22886-状态2", Easing.Linear, 1)

SetPosition

  • 参数及类型:
  • 返回值及类型:
  • 该方法的其他说明: 设置指定元件在界面上的坐标位置
  • 具体使用案例如下:
lua
    local isSuccess = CustomUI:SetPosition(Player:GetHostUin(),"7482986899365911542-22886","7482986899365911542-22886_1", 600, 200)

SetScale

  • 参数及类型:
  • 返回值及类型:
  • 该方法的其他说明: 设置指定元件的缩放比例
  • 具体使用案例如下:
lua
    local isSuccess = CustomUI:SetScale(Player:GetHostUin(),"7482986899365911542-22886","7482986899365911542-22886_1", 2, 2)

GetItemIcon

  • 参数及类型:
    • itemid:number,string道具类型ID/预制ID
  • 返回值及类型:
    • icon:string道具图标标识;失败返回""
  • 该方法的其他说明: 根据道具类型ID/预制ID获取道具图标
  • 具体使用案例如下:
lua
    local icon = CustomUI:GetItemIcon(12004)

    if icon and icon ~= "" then

        print("获取图标成功")

    end

GetMonsterObjIcon

  • 参数及类型:
  • 返回值及类型:
    • icon:string生物图标标识;无效返回""
  • 该方法的其他说明: 根据生物对象ID获取对应的生物图标标识字符串
  • 具体使用案例如下:
lua
    local obj = GameObject:CreatePrefabInst("r1_7482990429829028854_22890", nil, 10,8,10)

    if obj then

        local icon = CustomUI:GetMonsterObjIcon(obj:GetId())

        if icon and icon ~= "" then

            print("获取怪物图标成功")

        end

    end

GetMonsterIcon

  • 参数及类型:
    • actorid:number,string生物类型ID/预制ID
  • 返回值及类型:
    • icon:string生物图标标识;无效返回""
  • 该方法的其他说明: 根据生物类型ID/预制ID生成生物图标标识字符串
  • 具体使用案例如下:
lua
    local icon = CustomUI:GetMonsterIcon(3400)

    if icon and icon ~= "" then

        print("获取怪物图标成功")

    end

GetStatusIcon

  • 参数及类型:
    • buffid:number,string状态ID/预制ID
  • 返回值及类型:
    • icon:string状态图标标识;无效返回""或nil
  • 该方法的其他说明: 根据状态ID/预制ID获取状态图标标识字符串
  • 具体使用案例如下:
lua
    local icon = CustomUI:GetStatusIcon(4001)

    if icon and icon ~= "" then

        print("获取状态图标成功")

    end

GetBlockIcon

  • 参数及类型:
    • blockid:number,string方块类型ID/预制ID
  • 返回值及类型:
    • icon:string方块图标标识;无效返回""
  • 该方法的其他说明: 根据方块类型ID/预制ID生成方块图标标识字符串
  • 具体使用案例如下:
lua
    local icon = CustomUI:GetBlockIcon(200)

    if icon and icon ~= "" then

        print("获取方块图标成功")

    end

GetRoleIcon

  • 参数及类型:
  • 返回值及类型:
    • icon:string角色图标标识;失败返回nil
  • 该方法的其他说明: 获取玩家当前角色的图标标识字符串
  • 具体使用案例如下:
lua
    local icon = CustomUI:GetRoleIcon(Player:GetHostUin())

    if icon and icon ~= "" then

        print("获取角色图标成功")

    end

GetRoleHeadIcon

  • 参数及类型:
  • 返回值及类型:
  • 该方法的其他说明: 根据玩家ID生成默认头像图标标识字符串
  • 具体使用案例如下:
lua
    local icon = CustomUI:GetRoleHeadIcon(Player:GetHostUin())

    if icon and icon ~= "" then

        print("获取角色头像成功")

    end

GetShortcutIcon

  • 参数及类型:
  • 返回值及类型:
    • icon:string道具图标标识;失败返回nil
  • 该方法的其他说明: 获取玩家快捷栏指定格子的道具图标标识字符串
  • 具体使用案例如下:
lua
    local icon = CustomUI:GetShortcutIcon(Player:GetHostUin(), 1)

SmoothMoveTo

  • 参数及类型:
  • 返回值及类型:
  • 该方法的其他说明: 让元件在指定时间内平滑移动到绝对坐标位置
  • 具体使用案例如下:
lua
    local isSuccess = CustomUI:SmoothMoveTo(Player:GetHostUin(),"7482986899365911542-22886","7482986899365911542-22886_4", 1, 200, 300)

SmoothMoveBy

  • 参数及类型:
  • 返回值及类型:
  • 该方法的其他说明: 让元件在指定时间内按相对距离平滑移动
  • 具体使用案例如下:
lua
    local isSuccess = CustomUI:SmoothMoveBy(Player:GetHostUin(),"7482986899365911542-22886","7482986899365911542-22886_1", 1, 100, 100)

SmoothScaleTo

  • 参数及类型:
  • 返回值及类型:
  • 该方法的其他说明: 让元件在指定时间内平滑改变到指定宽度和高度
  • 具体使用案例如下:
lua
    local isSuccess = CustomUI:SmoothScaleTo(Player:GetHostUin(),"7482986899365911542-22886","7482986899365911542-22886_1", 1, 100, 200)

SmoothScaleBy

  • 参数及类型:
  • 返回值及类型:
  • 该方法的其他说明: 让元件在指定时间内按相对增量平滑改变宽度和高度
  • 具体使用案例如下:
lua
    local isSuccess = CustomUI:SmoothScaleBy(Player:GetHostUin(),"7482986899365911542-22886","7482986899365911542-22886_1", 1, 30, 20)

SmoothScaleByEx

  • 参数及类型:
  • 返回值及类型:
  • 该方法的其他说明: 让元件在指定时间内平滑改变相对缩放大小(子节点也会改变大小)<1.47+>
  • 具体使用案例如下:
lua
    local isSuccess = CustomUI:SmoothScaleByEx(Player:GetHostUin(),"7482986899365911542-22886","7482986899365911542-22886_1",5, 3, 3)

SmoothRotateTo

  • 参数及类型:
  • 返回值及类型:
  • 该方法的其他说明: 让元件在指定时间内平滑旋转到指定角度
  • 具体使用案例如下:
lua
    local isSuccess = CustomUI:SmoothRotateTo(Player:GetHostUin(),"7482986899365911542-22886","7482986899365911542-22886_1", 1, 45)

SmoothRotateBy

  • 参数及类型:
  • 返回值及类型:
  • 该方法的其他说明: 让元件在指定时间内按相对角度平滑旋转
  • 具体使用案例如下:
lua
    local isSuccess = CustomUI:SmoothRotateBy(Player:GetHostUin(),"7482986899365911542-22886","7482986899365911542-22886_1", 1, 20)

PlayElementAnim

  • 参数及类型:
  • 返回值及类型:
  • 该方法的其他说明: 播放元件动画(动效/缓动/延迟等参数按配置生效)
  • 具体使用案例如下:
lua
    local isSuccess = CustomUI:PlayElementAnim(Player:GetHostUin(),"7482986899365911542-22886","7482986899365911542-22886_1", 30007, 1, ViedoPlayMode.Once)

StopAnim

  • 参数及类型:
  • 返回值及类型:
  • 该方法的其他说明: 停止元件动画(可停止全部动效或指定元件动效)
  • 具体使用案例如下:
lua
    local isSuccess = CustomUI:StopAnim(Player:GetHostUin(),"7482986899365911542-22886","7482986899365911542-22886_1", 0)

SetLoaderModel

  • 参数及类型:
  • 返回值及类型:
  • 该方法的其他说明: 设置装载器元件显示的模型(支持按约定格式解析模型来源)
  • 具体使用案例如下:
lua
    local isSuccess = CustomUI:SetLoaderModel(Player:GetHostUin(),"7482986899365911542-22886","7482986899365911542-22886_5", "mob_3419")

SetLoaderModelScale

  • 参数及类型:
  • 返回值及类型:
  • 该方法的其他说明: 设置装载器元件模型缩放大小
  • 具体使用案例如下:
lua
    local isSuccess = CustomUI:SetLoaderModelScale(Player:GetHostUin(),"7482986899365911542-22886","7482986899365911542-22886_5", 1.5)

SetLoaderModelDir

  • 参数及类型:
  • 返回值及类型:
  • 该方法的其他说明: 设置装载器元件模型的水平旋转角度
  • 具体使用案例如下:
lua
    local isSuccess = CustomUI:SetLoaderModelDir(Player:GetHostUin(),"7482986899365911542-22886","7482986899365911542-22886_5", 90)

SetLoaderModelPosition

  • 参数及类型:
  • 返回值及类型:
  • 该方法的其他说明: 设置装载器元件模型的位置坐标
  • 具体使用案例如下:
lua
    local isSuccess = CustomUI:SetLoaderModelPosition(Player:GetHostUin(),"7482986899365911542-22886","7482986899365911542-22886_5", 100, 200, 300)

SetLoaderModelAct

  • 参数及类型:
  • 返回值及类型:
  • 该方法的其他说明: 设置装载器元件模型播放的动画
  • 具体使用案例如下:
lua
    local isSuccess = CustomUI:SetLoaderModelAct(Player:GetHostUin(),"7482986899365911542-22886","7482986899365911542-22886_5", "100100", AnimMode.Default,1)

TurnSliderToPos

  • 参数及类型:
  • 返回值及类型:
  • 该方法的其他说明: 让滑动列表跳转到指定坐标位置
  • 具体使用案例如下:
lua
    local isSuccess = CustomUI:TurnSliderToPos(Player:GetHostUin(), "7482986899365911542-22886","7482986899365911542-22886_6",0, 50)

SetSliderDir

  • 参数及类型:
    • playerid:number玩家ID
    • uiid:string界面ID
    • elementid:string元件ID
    • dir:number滑动方式(0仅左右/1仅上下/2自由滑动)
  • 返回值及类型:
  • 该方法的其他说明: 设置滑动列表的滑动方向限制
  • 具体使用案例如下:
lua
    local isSuccess = CustomUI:SetSliderDir(Player:GetHostUin(), "7482986899365911542-22886","7482986899365911542-22886_6", 1)

SetSliderBarImg

  • 参数及类型:
  • 返回值及类型:
  • 该方法的其他说明: 设置滑动条/滑动列表滑块的图案资源
  • 具体使用案例如下:
lua
    local isSuccess = CustomUI:SetSliderBarImg(Player:GetHostUin(), "7482986899365911542-22886","7482986899365911542-22886_6", 10100)

SetRelationPosition

lua
    local isSuccess = CustomUI:SetRelationPosition(Player:GetHostUin(), "7482986899365911542-22886", "7482986899365911542-22886_1", HorizontalOffset.Left, 10, PixelUnits.Percentage, VerticalOffset.Top, 10, PixelUnits.Percentage)

SetRelationSize

  • 参数及类型:
  • 返回值及类型:
  • 该方法的其他说明: 设置元件相对单位的宽高大小
  • 具体使用案例如下:
lua
    local isSuccess = CustomUI:SetRelationSize(Player:GetHostUin(), "7482986899365911542-22886","7482986899365911542-22886_7", 100, PixelUnits.Percentage, 100, PixelUnits.Percentage)

CreateElement

  • 参数及类型:
  • 返回值及类型:
    • elementid:string新建元件ID;失败返回nil/false
  • 该方法的其他说明: 动态创建元件并返回新元件ID,创建元件的子节点用 A.B 操作。
  • 具体使用案例如下:
lua
    local id = CustomUI:CreateElement(Player:GetHostUin(), "7482986899365911542-22886",ElementType.Texture)

    if id ~= nil then

        print("创建元件成功")

    end

CloneElement

  • 参数及类型:
  • 返回值及类型:
    • elementid:string克隆元件ID;失败返回nil/false
  • 该方法的其他说明: 克隆指定元件,并返回克隆后的新元件ID
  • 具体使用案例如下:
lua
    local id = CustomUI:CloneElement(Player:GetHostUin(), "7482986899365911542-22886", "7482986899365911542-22886_7")

    if id ~= nil then

        print("克隆元件成功")

    end

ChangeParent

  • 参数及类型:
  • 返回值及类型:
  • 该方法的其他说明: 修改元件的父元件(调整层级结构)
  • 具体使用案例如下:
lua
    local isSuccess = CustomUI:ChangeParent(Player:GetHostUin(), "7482986899365911542-22886", "7482986899365911542-22886_7", "7482986899365911542-22886_1")

    if isSuccess then

        print("改变父节点成功")

    end

SetProgressBarValue

  • 参数及类型:
  • 返回值及类型:
  • 该方法的其他说明: 设置进度条元件的数值(最小/最大/当前等,按类型枚举生效)
  • 具体使用案例如下:
lua
    local isSuccess = CustomUI:SetProgressBarValue(Player:GetHostUin(), "7482986899365911542-22886","7482986899365911542-22886_7", ProgressVal.Current, 100)

GetProgressBarValue

  • 参数及类型:
  • 返回值及类型:
  • 该方法的其他说明: 获取进度条元件的最小值/最大值/当前值,并通过reportid上报给主机
  • 具体使用案例如下:
lua
     local min,max,value = CustomUI:GetProgressBarValue(Player:GetHostUin(), "7482986899365911542-22886","7482986899365911542-22886_7")

SetProgressBarResId

  • 参数及类型:
  • 返回值及类型:
  • 该方法的其他说明: 设置进度条元件的纹理资源(背景/进度等,按类型枚举生效)
  • 具体使用案例如下:
lua
    local isSuccess = CustomUI:SetProgressBarResId(Player:GetHostUin(), "7482986899365911542-22886", "7482986899365911542-22886_7", ProgressImg.Background, 10100)

SmoothChangeProgress

  • 参数及类型:
  • 返回值及类型:
    • bool:boolean是否触发成功(无显式返回值时为nil)
  • 该方法的其他说明: 让进度条文本在指定时间内从起始值平滑变化到结束值
  • 具体使用案例如下:
lua
local bool = CustomUI:SmoothChangeProgress(playerid, uiid, elementid, bval, eval, time)

SetSpineAnimID

  • 参数及类型:
  • 返回值及类型:
  • 该方法的其他说明: 设置动画元件的动画ID/序列/播放模式
  • 具体使用案例如下:
lua
    local isSuccess = CustomUI:SetSpineAnimID(Player:GetHostUin(),"7482986899365911542-22886","7482986899365911542-22886_4", 10052, 1, ViedoPlayMode.Repeat)

SmoothIncreaseProgress

  • 参数及类型:
  • 返回值及类型:
  • 该方法的其他说明: 让进度条文本在指定时间内按类型平滑变化(增加/减少/变化至)
  • 具体使用案例如下:
lua
    local isSuccess = CustomUI:SmoothIncreaseProgress(Player:GetHostUin(), "7482986899365911542-22886","7482986899365911542-22886_7", 3, 1, 50)

SetFloatDamageTxt

  • 参数及类型:
  • 返回值及类型:
  • 该方法的其他说明: 在对象屏幕坐标附近显示浮动伤害文本,并按参数播放移动/渐隐效果
  • 具体使用案例如下:
lua
local bool = CustomUI:SetFloatDamageTxt(playerid, elementid, objid, text, color, offsetx, offsety, movex, movey, showtime, movex2, movey2, showtime2)

GetScreenSize

  • 参数及类型:
  • 返回值及类型:
  • 该方法的其他说明: 获取客机屏幕分辨率
  • 具体使用案例如下:
lua
    local width, height = CustomUI:GetScreenSize(Player:GetHostUin())

DeleteElement

  • 参数及类型:
  • 返回值及类型:
  • 该方法的其他说明: 删除UI元件
  • 具体使用案例如下:
lua
local bool = CustomUI:DeleteElement(playerid, uiid, elementid)

SetBeaconMapType

  • 参数及类型:
  • 返回值及类型:
  • 该方法的其他说明: 设置信标映射类型(0:位置;1:对象)
  • 具体使用案例如下:
lua
local bool = CustomUI:SetBeaconMapType(playerid, elementid, mapType)

SetBeaconBandPos

  • 参数及类型:
  • 返回值及类型:
  • 该方法的其他说明: 设置信标绑定位置坐标
  • 具体使用案例如下:
lua
local bool = CustomUI:SetBeaconBandPos(playerid, elementid, bandPosX, bandPosY, bandPosZ)

SetBeaconObjId

  • 参数及类型:
  • 返回值及类型:
  • 该方法的其他说明: 设置信标绑定的对象ID
  • 具体使用案例如下:
lua
local bool = CustomUI:SetBeaconObjId(playerid, elementid, objId)

SetBeaconOffset

  • 参数及类型:
  • 返回值及类型:
  • 该方法的其他说明: 设置信标偏移量
  • 具体使用案例如下:
lua
local bool = CustomUI:SetBeaconOffset(playerid, elementid, offsetX, offsetY, offsetZ)

SetBeaconClampType

  • 参数及类型:
  • 返回值及类型:
  • 该方法的其他说明: 设置信标限制范围类型
  • 具体使用案例如下:
lua
local bool = CustomUI:SetBeaconClampType(playerid, elementid, clampType)

SetBeaconRadius

  • 参数及类型:
  • 返回值及类型:
  • 该方法的其他说明: 设置信标显示半径
  • 具体使用案例如下:
lua
local bool = CustomUI:SetBeaconRadius(playerid, elementid, radius)