|
|
一开始我也遇到这个问题,直接打印了这个值,也是这样的,为了方便同样问题的不懂。
参考如下代码写就好了,不需要遍历的。
SL rint("--------------TestController.main------------------")
local parent = GUI:Win_Create("TestController.main")
GUI oadExport(parent, "../scripts/ssr/view/TestView",function ()
SL rint("加载UI成功")
end)
local parent_ui = GUI:ui_delegate(parent)
SL rint("--------------找到节1点----------a-------")
local Layout_1 = GUI:getChildByName(parent, "Layout_1")
if Layout_1 then
SL rint("找到按钮Layout_1,可以添加事件或修改属性")
else
SL rint("未找到按钮Layout_1,请检查控件名称和路径")
end
local parent_Layout_1_ui = GUI:ui_delegate(parent_ui.Layout_1)
GUI:addOnClickEvent(parent_Layout_1_ui.default_3, function()
SL rint("--------------exit----default_3_ui------a-------")
end)
SL rint("--------------找到节1点----------b-------")
下面是UI页面的lua代码
local ui = {}
function ui.init(parent)
local Layout_1 = GUI ayout_Create(parent, "Layout_1", 0, 0, 1, 1)
local Img_default_1 = GUI:Image_Create(Layout_1, "default_1", 0, 0, "res/public/bg_npc_01.png")
local Layout_default_2 = GUI ayout_Create(Layout_1, "default_2", 545, 0, 80, 80)
local Button_default_3 = GUI:Button_Create(Layout_1, "default_3", 546, 0, "res/public/1900000510.png")
end
return ui |
|