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(...)元件平滑改变相对宽度和高度
25SmoothRotateTo(...)元件平滑旋转到指定角度
26SmoothRotateBy(...)元件平滑旋转到相对角度
27PlayElementAnim(...)播放动画
28StopAnim(...)元件停止动画
29SetLoaderModel(...)设置装载器的模型
30SetLoaderModelScale(...)设置装载器的模型缩放
31SetLoaderModelDir(...)设置装载器的模型方向
32SetLoaderModelAct(...)设置装载器的模型动画
33TurnSliderToPos(...)滑动列表跳转到某位置
34SetSliderDir(...)设置滑动列表的滑动方式
35SetSliderBarImg(...)设置滑动条的图案
36SetRelationPosition(...)设置元件相对位置
37SetRelationSize(...)设置元件相对大小
38CreateElement(...)动态创建元件
39CloneElement(...)克隆元件
40ChangeParent(...)修改元件父元件
41SetProgressBarValue(...)设置玩家界面进度条的值
42GetProgressBarValue(...)获取玩家界面进度条的值
43SetProgressBarResId(...)设置玩家界面进度条的纹理
44SmoothChangeProgress(...)进度条文本平滑计时
45SetSpineAnimID(...)设置动画元件动画ID
46SmoothIncreaseProgress(...)进度条文本平滑增加计时
47GetScreenSize(...)获取客机屏幕分辨率

SetText

  • 参数及类型:
  • 返回值及类型:
    • ret:bool是否成功
  • 该方法的主要作用: 设置文本元件内容
  • 具体使用案例如下:
lua
    local isSuccess = CustomUI:SetText(Player:GetHostUin(),"7482986899365911542-22886","7482986899365911542-22886_2", "测试文本")

SetTexture

  • 参数及类型:
  • 返回值及类型:
    • ret:bool是否成功
  • 该方法的主要作用: 设置文本元件图案纹理
  • 具体使用案例如下:
lua
    local isSuccess = CustomUI:SetTexture(Player:GetHostUin(),"7482986899365911542-22886","7482986899365911542-22886_3", "0_10103")

SetSize

  • 参数及类型:
  • 返回值及类型:
    • ret:bool是否成功
  • 该方法的主要作用: 设置元件大小
  • 具体使用案例如下:
lua
    local isSuccess = CustomUI:SetSize(Player:GetHostUin(),"7482986899365911542-22886","7482986899365911542-22886_3", 200, 100)

SetFontSize

  • 参数及类型:
  • 返回值及类型:
    • ret:bool是否成功
  • 该方法的主要作用: 设置文本元件字体大小
  • 具体使用案例如下:
lua
    local isSuccess = CustomUI:SetFontSize(Player:GetHostUin(),"7482986899365911542-22886","7482986899365911542-22886_2", 20)

SetColor

  • 参数及类型:
  • 返回值及类型:
    • ret:bool是否成功
  • 该方法的主要作用: 设置文本元件颜色
  • 具体使用案例如下:
lua
    local isSuccess = CustomUI:SetColor(Player:GetHostUin(),"7482986899365911542-22886","7482986899365911542-22886_1", "0xf44336")

ShowElement

  • 参数及类型:
  • 返回值及类型:
    • ret:bool是否成功
  • 该方法的主要作用: 显示元件
  • 具体使用案例如下:
lua
    local isSuccess = CustomUI:ShowElement(Player:GetHostUin(),"7482986899365911542-22886","7482986899365911542-22886_1")

HideElement

  • 参数及类型:
  • 返回值及类型:
    • ret:bool是否成功
  • 该方法的主要作用: 隐藏元件
  • 具体使用案例如下:
lua
    local isSuccess = CustomUI:HideElement(Player:GetHostUin(),"7482986899365911542-22886","7482986899365911542-22886_1")

RotateElement

  • 参数及类型:
  • 返回值及类型:
    • ret:bool是否成功
  • 该方法的主要作用: 旋转元件
  • 具体使用案例如下:
lua
    local isSuccess = CustomUI:RotateElement(Player:GetHostUin(),"7482986899365911542-22886","7482986899365911542-22886_1", 45)

SetAlpha

  • 参数及类型:
  • 返回值及类型:
    • ret:bool是否成功
  • 该方法的主要作用: 设置透明度
  • 具体使用案例如下:
lua
    local isSuccess = CustomUI:SetAlpha(Player:GetHostUin(),"7482986899365911542-22886","7482986899365911542-22886_1", 0.5)

SetState

  • 参数及类型:
  • 返回值及类型:
    • ret:bool是否成功
  • 该方法的主要作用: 设置状态
  • 具体使用案例如下:
lua
    local isSuccess = CustomUI:SetState(Player:GetHostUin(),"7482986899365911542-22886","7482986899365911542-22886-状态2", Easing.Linear, 1)

SetPosition

  • 参数及类型:
  • 返回值及类型:
    • ret:bool是否成功
  • 该方法的主要作用: 设置位置
  • 具体使用案例如下:
lua
    local isSuccess = CustomUI:SetPosition(Player:GetHostUin(),"7482986899365911542-22886","7482986899365911542-22886_1", 600, 200)

SetScale

  • 参数及类型:
  • 返回值及类型:
    • ret:bool是否成功
  • 该方法的主要作用: 设置装载器的模型缩放
  • 具体使用案例如下:
lua
    local isSuccess = CustomUI:SetScale(Player:GetHostUin(),"7482986899365911542-22886","7482986899365911542-22886_1", 2, 2)

GetItemIcon

  • 参数及类型:
  • 返回值及类型:
  • 该方法的主要作用: 获取道具类型图标
  • 具体使用案例如下:
lua
    local icon = CustomUI:GetItemIcon(12004)

    if icon and icon ~= "" then

        print("获取图标成功")

    end

GetMonsterObjIcon

  • 参数及类型:
  • 返回值及类型:
  • 该方法的主要作用: 获取生物图标
  • 具体使用案例如下:
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

  • 参数及类型:
  • 返回值及类型:
  • 该方法的主要作用: 获取生物类型图标
  • 具体使用案例如下:
lua
    local icon = CustomUI:GetMonsterIcon(3400)

    if icon and icon ~= "" then

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

    end

GetStatusIcon

  • 参数及类型:
  • 返回值及类型:
  • 该方法的主要作用: 获取状态图标
  • 具体使用案例如下:
lua
    local icon = CustomUI:GetStatusIcon(4001)

    if icon and icon ~= "" then

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

    end

GetBlockIcon

  • 参数及类型:
  • 返回值及类型:
  • 该方法的主要作用: 获取方块类型图标
  • 具体使用案例如下:
lua
    local icon = CustomUI:GetBlockIcon(200)

    if icon and icon ~= "" then

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

    end

GetRoleIcon

  • 参数及类型:
  • 返回值及类型:
  • 该方法的主要作用: 获取玩家当前角色图标
  • 具体使用案例如下:
lua
    local icon = CustomUI:GetRoleIcon(Player:GetHostUin())

    if icon and icon ~= "" then

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

    end

GetRoleHeadIcon

  • 参数及类型:
  • 返回值及类型:
  • 该方法的主要作用: 获取玩家当前角色图标
  • 具体使用案例如下:
lua
    local icon = CustomUI:GetRoleHeadIcon(Player:GetHostUin())

    if icon and icon ~= "" then

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

    end

GetShortcutIcon

  • 参数及类型:
  • 返回值及类型:
  • 该方法的主要作用: 获取玩家快捷栏图标
  • 具体使用案例如下:
lua
    local icon = CustomUI:GetShortcutIcon(Player:GetHostUin(), 1)

SmoothMoveTo

  • 参数及类型:
  • 返回值及类型:
    • ret:bool是否成功
  • 该方法的主要作用: 元件平滑移动到指定位置
  • 具体使用案例如下:
lua
    local isSuccess = CustomUI:SmoothMoveTo(Player:GetHostUin(),"7482986899365911542-22886","7482986899365911542-22886_4", 1, 200, 300)

SmoothMoveBy

  • 参数及类型:
  • 返回值及类型:
    • ret:bool是否成功
  • 该方法的主要作用: 元件平滑移动相对距离
  • 具体使用案例如下:
lua
    local isSuccess = CustomUI:SmoothMoveBy(Player:GetHostUin(),"7482986899365911542-22886","7482986899365911542-22886_1", 1, 100, 100)

SmoothScaleTo

  • 参数及类型:
  • 返回值及类型:
    • ret:bool是否成功
  • 该方法的主要作用: 元件平滑改变到指定宽度和高度
  • 具体使用案例如下:
lua
    local isSuccess = CustomUI:SmoothScaleTo(Player:GetHostUin(),"7482986899365911542-22886","7482986899365911542-22886_1", 1, 100, 200)

SmoothScaleBy

  • 参数及类型:
  • 返回值及类型:
    • ret:bool是否成功
  • 该方法的主要作用: 元件平滑改变相对宽度和高度
  • 具体使用案例如下:
lua
    local isSuccess = CustomUI:SmoothScaleBy(Player:GetHostUin(),"7482986899365911542-22886","7482986899365911542-22886_1", 1, 30, 20)

SmoothRotateTo

  • 参数及类型:
  • 返回值及类型:
    • ret:bool是否成功
  • 该方法的主要作用: 元件平滑旋转到指定角度
  • 具体使用案例如下:
lua
    local isSuccess = CustomUI:SmoothRotateTo(Player:GetHostUin(),"7482986899365911542-22886","7482986899365911542-22886_1", 1, 45)

SmoothRotateBy

  • 参数及类型:
  • 返回值及类型:
    • ret:bool是否成功
  • 该方法的主要作用: 元件平滑旋转到相对角度
  • 具体使用案例如下:
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

  • 参数及类型:
    • playerid:number玩家ID
    • uiid:string界面ID
    • elementid:number元件ID
    • itype:number类型(如果为0就是停止所有的UI的动效,1就是停止elementid对应的UI动效)lement
  • 返回值及类型:
    • ret:bool是否成功
  • 该方法的主要作用: 元件停止动画
  • 具体使用案例如下:
lua
    local isSuccess = CustomUI:StopAnim(Player:GetHostUin(),"7482986899365911542-22886","7482986899365911542-22886_1", 0)

SetLoaderModel

  • 参数及类型:
    • playerid:number玩家ID
    • uiid:string界面ID
    • elementid:string元件ID
    • 枪械 modelName:{itemId = 100
    • level = 1},非枪械 modleName:string模型名称
  • 返回值及类型:
    • ret:bool是否成功
  • 该方法的主要作用: 设置装载器的模型
  • 具体使用案例如下:
lua
    local isSuccess = CustomUI:SetLoaderModel(Player:GetHostUin(),"7482986899365911542-22886","7482986899365911542-22886_5", "mob_3419")

SetLoaderModelScale

  • 参数及类型:
  • 返回值及类型:
    • ret:bool是否成功
  • 该方法的主要作用: 设置装载器的模型缩放
  • 具体使用案例如下:
lua
    local isSuccess = CustomUI:SetLoaderModelScale(Player:GetHostUin(),"7482986899365911542-22886","7482986899365911542-22886_5", 1.5)

SetLoaderModelDir

  • 参数及类型:
  • 返回值及类型:
    • ret:bool是否成功
  • 该方法的主要作用: 设置装载器的模型方向
  • 具体使用案例如下:
lua
    local isSuccess = CustomUI:SetLoaderModelDir(Player:GetHostUin(),"7482986899365911542-22886","7482986899365911542-22886_5", 90)

SetLoaderModelAct

  • 参数及类型:
  • 返回值及类型:
    • ret:bool是否成功
  • 该方法的主要作用: 设置装载器的模型动画
  • 具体使用案例如下:
lua
    local isSuccess = CustomUI:SetLoaderModelAct(Player:GetHostUin(),"7482986899365911542-22886","7482986899365911542-22886_5", "100100", 1, AnimMode.Default)

TurnSliderToPos

  • 参数及类型:
  • 返回值及类型:
    • ret:bool是否成功
  • 该方法的主要作用: 滑动列表跳转到某位置
  • 具体使用案例如下:
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自由滑动)
  • 返回值及类型:
    • ret:bool是否成功
  • 该方法的主要作用: 设置滑动列表的滑动方式
  • 具体使用案例如下:
lua
    local isSuccess = CustomUI:SetSliderDir(Player:GetHostUin(), "7482986899365911542-22886","7482986899365911542-22886_6", 1)

SetSliderBarImg

  • 参数及类型:
  • 返回值及类型:
    • ret:bool是否成功
  • 该方法的主要作用: 设置滑动条的图案
  • 具体使用案例如下:
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

  • 参数及类型:
  • 返回值及类型:
    • ret:bool是否成功
  • 该方法的主要作用: 设置元件相对大小
  • 具体使用案例如下:
lua
    local isSuccess = CustomUI:SetRelationSize(Player:GetHostUin(), "7482986899365911542-22886","7482986899365911542-22886_7", 100, PixelUnits.Percentage, 100, PixelUnits.Percentage)

CreateElement

  • 参数及类型:
  • 返回值及类型:
    • elementid:string新建出来元件ID
  • 该方法的主要作用: 动态创建元件
  • 具体使用案例如下:
lua
    local id = CustomUI:CreateElement(Player:GetHostUin(), "7482986899365911542-22886",ElementType.Texture)

    if id ~= nil then

        print("创建元件成功")

    end

CloneElement

  • 参数及类型:
  • 返回值及类型:
    • elementid:string克隆出来的元件ID
  • 该方法的主要作用: 克隆元件
  • 具体使用案例如下:
lua
    local id = CustomUI:CloneElement(Player:GetHostUin(), "7482986899365911542-22886", "7482986899365911542-22886_7")

    if id ~= nil then

        print("克隆元件成功")

    end

ChangeParent

  • 参数及类型:
  • 返回值及类型:
    • ret:bool是否成功
  • 该方法的主要作用: 修改元件父元件
  • 具体使用案例如下:
lua
    local isSuccess = CustomUI:ChangeParent(Player:GetHostUin(), "7482986899365911542-22886", "7482986899365911542-22886_7", "7482986899365911542-22886_1")

    if isSuccess then

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

    end

SetProgressBarValue

  • 参数及类型:
  • 返回值及类型:
    • ret:bool是否成功
  • 该方法的主要作用: 设置玩家界面进度条的值
  • 具体使用案例如下:
lua
    local isSuccess = CustomUI:SetProgressBarValue(Player:GetHostUin(), "7482986899365911542-22886","7482986899365911542-22886_7", ProgressVal.Current, 100)

GetProgressBarValue

  • 参数及类型:
  • 返回值及类型:
  • 该方法的主要作用: 获取玩家界面进度条的值
  • 具体使用案例如下:
lua
     local min,max,value = CustomUI:GetProgressBarValue(Player:GetHostUin(), "7482986899365911542-22886","7482986899365911542-22886_7")

SetProgressBarResId

  • 参数及类型:
  • 返回值及类型:
    • ret:bool是否成功
  • 该方法的主要作用: 设置玩家界面进度条的纹理
  • 具体使用案例如下:
lua
    local isSuccess = CustomUI:SetProgressBarResId(Player:GetHostUin(), "7482986899365911542-22886", "7482986899365911542-22886_7", ProgressImg.Background, 10100)

SmoothChangeProgress

  • 参数及类型:
  • 返回值及类型:
    • ret:bool是否成功
  • 该方法的主要作用: 进度条文本平滑计时
  • 具体使用案例如下:
lua
local ret = CustomUI:SmoothChangeProgress(playerid, uiid, elementid, bval, eval, time)

SetSpineAnimID

  • 参数及类型:
  • 返回值及类型:
    • ret:bool是否成功
  • 该方法的主要作用: 设置动画元件动画ID
  • 具体使用案例如下:
lua
    local isSuccess = CustomUI:SetSpineAnimID(Player:GetHostUin(),"7482986899365911542-22886","7482986899365911542-22886_4", 10052, 1, ViedoPlayMode.Repeat)

SmoothIncreaseProgress

  • 参数及类型:
  • 返回值及类型:
    • ret:bool是否成功
  • 该方法的主要作用: 进度条文本平滑增加计时
  • 具体使用案例如下:
lua
    local isSuccess = CustomUI:SmoothIncreaseProgress(Player:GetHostUin(), "7482986899365911542-22886","7482986899365911542-22886_7", 3, 1, 50)

GetScreenSize

  • 参数及类型:
  • 返回值及类型:
    • size:table屏幕大小{w
    • h}
  • 该方法的主要作用: 获取客机屏幕分辨率
  • 具体使用案例如下:
lua
    local width, height = CustomUI:GetScreenSize(Player:GetHostUin())