DropDownItem = DropDownItem or BaseClass(BaseItem) DropDownItem.HEIGHT = 52 function DropDownItem:__init(parent_wnd) self.base_file = "uiComponent" self.layout_file = "DropDownItem" self:Load() end function DropDownItem:__delete() end function DropDownItem:Load_callback() self.name_text = self:GetChild("name"):GetComponent("Text") self.redDot = self:GetChild("redDot").gameObject self.select_img = self.transform:GetComponent("Image") self:InitEvent() if self.need_refresh then self:SetData(self.name, self.set_func, self.call_back) self:ShowRedDot(self.show_redDot) end if self.need_refreshSelect then self:SelectStatus(self.is_select) end end function DropDownItem:InitEvent() local function click_func(target) if self.set_func then self.set_func(self.name) end if self.call_back then self.call_back(self.name) end end AddClickEvent(self.gameObject, click_func) end function DropDownItem:SetData(name, set_func, call_back) self.name = name self.set_func = set_func self.call_back = call_back if self.is_loaded then self.name_text.text = self.name else self.need_refresh = true end end function DropDownItem:SetSelected() if self.set_func then self.set_func(self.name) end if self.call_back and self.name then self.call_back(self.name) end end function DropDownItem:ShowRedDot(value) self.show_redDot = value or false if self.is_loaded then self.redDot:SetActive(self.show_redDot) else self.need_refresh = true end end function DropDownItem:SelectStatus(bool) self.is_select = bool if self.is_loaded then lua_resM:setImageSprite(self, self.select_img, "common_asset", bool and "tips_btn_on" or "tips_btn_off") else self.need_refreshSelect = true end end