--子一级的tabbar按钮(单个按钮) UIVerTabSubBtn = UIVerTabSubBtn or BaseClass(BaseComponent) local UIVerTabSubBtn = UIVerTabSubBtn UIVerTabSubBtn.Height = 49 function UIVerTabSubBtn:__init(parent, call_back, desc) self.sub_index = 1 self.parent_idnex = 1 self.call_back = nil self:CreateGameObject(UIType.UIVerTabSubBtn) self:InitData(call_back, desc) end function UIVerTabSubBtn:InitData(call_back, text) self.call_back = call_back self.btnText.text = text end function UIVerTabSubBtn:LoadSuccess() self.btnText = self:GetChild("Button/Text"):GetComponent("TextMeshProUGUI") self.selectBg = self:GetChild("Button/selectBg").gameObject self.selectBg_con = self:GetChild("Button/selectBg") self.Button_con = self:GetChild("Button") self.Button = self:GetChild("Button").gameObject self.img = self:GetChild("Button/img"):GetComponent("Image") self.img.gameObject:SetActive(false) self.button_image = self:GetChild("Button"):GetComponent("Image") self.dot = self:GetChild("Button/dot").gameObject self.des_effect = self:GetChild("Button/effect") self.des_img = self:GetChild("Button/image_source") self.des_txt = self:GetChild("Button/Text") self.line = self:GetChild("Button/line").gameObject self.des_effect.gameObject:SetActive(false) self.des_img.gameObject:SetActive(false) self.line:SetActive(true) self:InitEvent() end function UIVerTabSubBtn:InitEvent() end function UIVerTabSubBtn:SetSubDeail(text, parent_idnex, sub_index, call_back) self.parent_idnex = parent_idnex self.sub_index = sub_index self.call_back = call_back self:SetText(text) end function UIVerTabSubBtn:SetText(str) self.btnText.text = str end function UIVerTabSubBtn:ResetSubDeail(data) self.data = data self.scale = 1 if self.data == nil then return end if self.data.type == 1 then --特效显示 self.des_txt.gameObject:SetActive(false) self.des_effect.gameObject:SetActive(true) self.des_img.gameObject:SetActive(false) self:AddUIEffect("effect_designation_" .. self.data.id, self.des_effect.transform, "Activity", nil, scale, true) elseif self.data.type == 2 then --文字显示 self.des_effect.gameObject:SetActive(false) self.des_txt.gameObject:SetActive(true) self.des_img.gameObject:SetActive(false) self.des_txt:GetComponent("Outline").effectColor = ColorUtil:GetGoodsColor(self.data.color) self.des_txt:GetComponent("Text").text = "".. self.data.name .."" SetLocalScale(self.des_txt.transform, scale) elseif self.data.type == 3 then -- 图片显示 self.des_effect.gameObject:SetActive(false) self.des_txt.gameObject:SetActive(false) local call_back = function ( ) self.des_img.gameObject:SetActive(true) end lua_resM:setOutsideImageSprite(self,self.des_img:GetComponent("ImageExtend"),GameResPath.GetDesignImage(self.data.goods_id),true,call_back) self.des_img:GetComponent("ImageExtend").gray = false if not DesignationModel:getInstance():GetDesignationByID(self.data.id) then self.des_img:GetComponent("ImageExtend").gray = true end SetLocalScale(self.des_img.transform, scale) elseif self.data.type == 4 then -- 特殊显示 self.des_effect.gameObject:SetActive(false) self.des_txt.gameObject:SetActive(false) local call_back = function ( ) self.des_img.gameObject:SetActive(true) end lua_resM:setOutsideImageSprite(self,self.des_img:GetComponent("ImageExtend"),GameResPath.GetDesignImage(self.data.goods_id),true,call_back) self.des_img:GetComponent("ImageExtend").gray = false if not DesignationModel:getInstance():GetDesignationByID(self.data.id) then self.des_img:GetComponent("ImageExtend").gray = true end SetLocalScale(self.des_img.transform, scale) end end function UIVerTabSubBtn:SetSelected(bool) if self.btnText then local normal_color = self.style_data and self.style_data.sub_btn_text_color_nor or Color(167/255,190/255,222/255,1) local select_color = self.style_data and self.style_data.sub_btn_text_color_sel or ColorUtil:ConvertHexToRGBColor( ColorUtil.WHITE_DARK ) self.btnText.color = (not bool) and normal_color or select_color end if self.selectBg then self.selectBg:SetActive(bool) end if bool and self.parent_idnex and self.sub_index then if self.call_back then self.call_back(self.parent_idnex, self.sub_index) end end end --设置大小 function UIVerTabSubBtn:SetTabSubBtnSize(data) self.Button_con.sizeDelta = Vector2(data.SUB_CON_WIDTH,data.SUB_CON_HEIGHT) self.selectBg_con.sizeDelta = Vector2(data.SUB_CON_WIDTH,data.SUB_CON_HEIGHT) end function UIVerTabSubBtn:SetStyleData( style_data ) self.style_data = style_data self:SetTabSubBtnSize(style_data) end function UIVerTabSubBtn:SetSelectState(b) if self.selectBg then self.selectBg:SetActive(b) self.line:SetActive(not b) end end function UIVerTabSubBtn:SetImageTexture(asset_path,res_name) if asset_path and res_name then self.img.gameObject:SetActive(true) lua_resM:setImageSprite(self,self.img,asset_path,res_name) else self.img.gameObject:SetActive(false) end end function UIVerTabSubBtn:ShowRedDot(bool) if self.dot then self.dot:SetActive(bool) end end function UIVerTabSubBtn:SetNewSource(data) self:SetTabSubBtnSize(data) lua_resM:setImageSprite(self,self.button_image,data.subabname,data.sub_normal) lua_resM:setImageSprite(self,self.selectBg:GetComponent("Image"),data.subabname,data.sub_select) end