76 lines
1.4 KiB
Plaintext
76 lines
1.4 KiB
Plaintext
require "BaseClass"
|
|
|
|
-- 公共类别修改只能用
|
|
CommonMenuItem = {}
|
|
|
|
local textUI
|
|
local textHotUI
|
|
local redGo
|
|
local redUI
|
|
local bkUI
|
|
local curItemData
|
|
|
|
function CommonMenuItem.Awake()
|
|
bkUI = self.transform:Find("BG")
|
|
textUI = title:GetComponent("Text")
|
|
textHotUI = titleHot:GetComponent("Text")
|
|
redGo = redIcon
|
|
redUI = redTimes:GetComponent("Text")
|
|
end
|
|
|
|
function CommonMenuItem.Start()
|
|
|
|
end
|
|
|
|
function CommonMenuItem.ShowWithTab(itemData)
|
|
curItemData = itemData
|
|
-- print("CommonMenuItem.ShowWithTab(itemData):%s",tostring(curItemData.name))
|
|
local name = itemData.name or ""
|
|
local redNum = itemData.redNum or 0
|
|
if name then
|
|
textUI.text = name
|
|
textHotUI.text = name
|
|
end
|
|
|
|
redGo:SetActive(false)
|
|
if redNum > 0 then
|
|
redGo:SetActive(true)
|
|
redUI.text = tostring(redNum)
|
|
end
|
|
|
|
-- 如果是按钮增加按钮回调
|
|
if bkUI then
|
|
local btnUI = bkUI:GetComponent("Button")
|
|
if btnUI then
|
|
btnUI.onClick:RemoveAllListeners()
|
|
btnUI.onClick:AddListener(function()
|
|
CommonMenuItem.OnItemClick()
|
|
end)
|
|
end
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
function CommonMenuItem.OnItemClick()
|
|
|
|
-- print("CommonMenuItem.OnItemClick()"..curItemData.name)
|
|
local pageType = curItemData.pageType
|
|
|
|
if curItemData.callback then
|
|
curItemData.callback(pageType)
|
|
end
|
|
end
|
|
|
|
function CommonMenuItem.Select()
|
|
selectedGo:SetActive(true)
|
|
end
|
|
|
|
function CommonMenuItem.UnSelect()
|
|
selectedGo:SetActive(false)
|
|
|
|
end
|