UGCProjects/TrainingCamp/Script/UI/InTest/WB_TestButtonItem.lua

46 lines
1.2 KiB
Lua
Raw Permalink Normal View History

2025-01-04 23:00:19 +08:00
---@class WB_TestButtonItem_C:UUserWidget
---@field Button_0 UButton
---@field TextBlock_0 UTextBlock
--Edit Below--
---@type WB_TestButtonItem_C
local WB_TestButtonItem = { bInitDoOnce = false; };
WB_TestButtonItem.Func = nil;
WB_TestButtonItem.OwnerParent = nil;
function WB_TestButtonItem:Construct()
UGCLogSystem.Log("[WB_TestButtonItem:Construct] 执行")
self.Button_0.OnClicked:Add(function()
UGCLogSystem.Log("[WB_TestButtonItem:Construct] 点击")
if self.Func and self.OwnerParent then
self.Func(self.OwnerParent)
end
end, self)
self.bInitDoOnce = true;
end
-- function WB_TestButtonItem:Tick(MyGeometry, InDeltaTime)
-- end
-- function WB_TestButtonItem:Destruct()
-- end
function WB_TestButtonItem:SetFunc(InFunc, InParent, InText)
UGCLogSystem.Log("[WB_TestButtonItem:SetFunc] InParent = %s", UE.GetName(InParent))
self.Func = InFunc;
self.OwnerParent = InParent;
if InText then
self.TextBlock_0:SetText(InText);
end
if self.bInitDoOnce then return end
self.Button_0.OnClicked:Add(function()
UGCLogSystem.Log("[WB_TestButtonItem:Construct] 点击")
if self.Func and self.OwnerParent then
self.Func(self.OwnerParent)
end
end, self)
end
return WB_TestButtonItem;