源战役客户端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

74 lines
1.6 KiB

ComboxItem = ComboxItem or BaseClass(BaseItem)
local ComboxItem = ComboxItem
ComboxItem.Height = 38
function ComboxItem:__init(parent_wnd, prefab_asset, layer_name, prefab_data)
self.base_file = prefab_asset or "uiComponent"
if prefab_data and prefab_data.ComboxItem then
self.layout_file = prefab_data and prefab_data.ComboxItem
else
self.layout_file = "ComboxItem"
end
self.show_red = nil
self:Load()
end
function ComboxItem:Load_callback()
self:LoadSuccess()
end
function ComboxItem:LoadSuccess()
self.show_text = self:GetChild("text"):GetComponent(typeof(TMPro.TextMeshProUGUI))
self.img_red_obj = self:GetChild("img_red").gameObject
self.di_line = self:GetChild("bg_41_1")
if self.width then
self:SetWidth(self.width)
end
self:AddEvents()
if self.need_refreshData then
self:UpdateView()
end
end
function ComboxItem:SetWidth(width)
self.width = width
if self.is_loaded then
self.need_resetWidth = false
SetSizeDeltaX(self.transform, self.width)
else
self.need_resetWidth = true
end
end
function ComboxItem:AddEvents( )
local function onClick(...)
if self.callback then
self.callback(self.index)
end
end
AddClickEvent(self.gameObject,onClick)
end
function ComboxItem:UpdateView( )
self.show_text.text = self.str
self.img_red_obj:SetActive(self.show_red and true or false)
end
function ComboxItem:SetData(index,str,callback,show_red)
self.index = index
self.str = str
self.callback = callback
self.show_red = show_red
if self.is_loaded then
self.need_refreshData = false
self:UpdateView()
else
self.need_refreshData = true
end
end
function ComboxItem:__delete( )
end