2020-07-04 14:41:25 +08:00
|
|
|
|
---@class CellBottomBtn
|
|
|
|
|
|
local _cell = {}
|
|
|
|
|
|
local csSelf = nil
|
|
|
|
|
|
local transform = nil
|
|
|
|
|
|
local mData = nil
|
|
|
|
|
|
local uiobjs = {}
|
|
|
|
|
|
|
|
|
|
|
|
-- 初始化,只调用一次
|
|
|
|
|
|
function _cell.init(csObj)
|
|
|
|
|
|
csSelf = csObj
|
|
|
|
|
|
transform = csSelf.transform
|
|
|
|
|
|
--[[
|
|
|
|
|
|
上的组件:getChild(transform, "offset", "Progress BarHong"):GetComponent("UISlider");
|
|
|
|
|
|
--]]
|
|
|
|
|
|
---@type UIToggle
|
|
|
|
|
|
uiobjs.toggle = csSelf:GetComponent("UIToggle")
|
|
|
|
|
|
uiobjs.Label = getCC(transform, "Label", "UILabel")
|
|
|
|
|
|
-- uiobjs.LabelCheck = getCC(transform, "LabelCheck", "UILabel")
|
|
|
|
|
|
uiobjs.boxCollider = csSelf:GetComponent("BoxCollider")
|
|
|
|
|
|
uiobjs.Background = getCC(transform, "Background", "UISprite")
|
|
|
|
|
|
uiobjs.Checkmark = getCC(transform, "Checkmark", "UISprite")
|
|
|
|
|
|
uiobjs.LabelReddotNum = getCC(transform, "LabelReddotNum", "UILabel")
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
-- 显示,
|
|
|
|
|
|
-- 注意,c#侧不会在调用show时,调用refresh
|
|
|
|
|
|
function _cell.show(go, data)
|
|
|
|
|
|
mData = data
|
|
|
|
|
|
uiobjs.Label.text = mData.name
|
|
|
|
|
|
-- uiobjs.LabelCheck.text = mData.name
|
|
|
|
|
|
uiobjs.boxCollider.center = Vector3.zero
|
|
|
|
|
|
uiobjs.boxCollider.size = Vector3(mData.width, 150, 0)
|
|
|
|
|
|
uiobjs.Background.spriteName = mData.Background
|
|
|
|
|
|
uiobjs.Checkmark.spriteName = mData.Checkmark
|
2020-08-05 20:46:00 +08:00
|
|
|
|
if mData.id == 1 then
|
|
|
|
|
|
local unreadNum = DBMessage.getUnreadNum(DBMessage.MsgType.Sys)
|
|
|
|
|
|
_cell.setReddotNum(unreadNum)
|
|
|
|
|
|
else
|
|
|
|
|
|
_cell.setReddotNum(0)
|
|
|
|
|
|
end
|
2020-07-04 14:41:25 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function _cell.setReddotNum(num)
|
|
|
|
|
|
if num and num > 0 then
|
|
|
|
|
|
SetActive(uiobjs.LabelReddotNum.gameObject, true)
|
|
|
|
|
|
if num > 9 then
|
|
|
|
|
|
uiobjs.LabelReddotNum.text = "…"
|
|
|
|
|
|
else
|
|
|
|
|
|
uiobjs.LabelReddotNum.text = tostring(num)
|
|
|
|
|
|
end
|
|
|
|
|
|
else
|
|
|
|
|
|
SetActive(uiobjs.LabelReddotNum.gameObject, false)
|
|
|
|
|
|
end
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
-- 注意,c#侧不会在调用show时,调用refresh
|
|
|
|
|
|
function _cell.setSelected(val)
|
|
|
|
|
|
uiobjs.toggle:Set(val)
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function _cell.refreshState()
|
|
|
|
|
|
if uiobjs.toggle.value then
|
|
|
|
|
|
uiobjs.Background.color = Color.white
|
|
|
|
|
|
uiobjs.Label.color = ColorEx.getColor(0xff2990dc)
|
|
|
|
|
|
else
|
|
|
|
|
|
uiobjs.Background.color = ColorEx.getColor(153, 153, 153)
|
|
|
|
|
|
uiobjs.Label.color = ColorEx.getColor(153, 153, 153)
|
|
|
|
|
|
end
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
-- 取得数据
|
|
|
|
|
|
function _cell.getData()
|
|
|
|
|
|
return mData
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function _cell.uiEventDelegate(go)
|
|
|
|
|
|
_cell.refreshState()
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--------------------------------------------
|
|
|
|
|
|
return _cell
|