|
InstructionItem = InstructionItem or BaseClass(BaseItem)
|
|
function InstructionItem:__init()
|
|
self.base_file = "common"
|
|
self.layout_file = "instructionItem"
|
|
self.height = 0
|
|
self:Load()
|
|
end
|
|
|
|
function InstructionItem:Load_callback()
|
|
self.titleText = self:GetChild("titleText"):GetComponent(typeof(TMPro.TextMeshProUGUI))
|
|
self.title_di = self:GetChild("title_di")
|
|
self.title_di_obj = self:GetChild("title_di").gameObject
|
|
self.line_obj = self:GetChild("line").gameObject
|
|
|
|
self.contentText = self:GetChild("contentText")
|
|
self.contentText_t = self:GetChild("contentText"):GetComponent(typeof(TMPro.TextMeshProUGUI))
|
|
end
|
|
|
|
function InstructionItem:SetData(vo)
|
|
if vo then
|
|
if vo.itemTitle=="" then --无需子标题
|
|
self.title_di_obj:SetActive(false)
|
|
self.line_obj:SetActive(false)
|
|
self.titleText.text = ""
|
|
self.contentText.transform.anchoredPosition = Vector2(25, 0)
|
|
else
|
|
self.title_di_obj:SetActive(true)
|
|
self.line_obj:SetActive(true)
|
|
self.titleText.text = vo.itemTitle
|
|
self.contentText.transform.anchoredPosition = Vector2(25, -45)
|
|
end
|
|
self.contentText_t.text = vo.content
|
|
|
|
SetLocalPositionX(self.title_di,GetLocalPositionX(self.titleText.transform)-(self.titleText.preferredWidth/2)-16)
|
|
--先把宽度设置好再计算文本高度,否则会导致计算错误
|
|
SetSizeDeltaX(self.contentText.transform,520)
|
|
self.height = self.contentText_t.preferredHeight + 10
|
|
self.contentText.sizeDelta = Vector2(520,self.height)
|
|
-- self.height = self.height + 32
|
|
self.height = self.height + 60
|
|
end
|
|
end
|
|
|
|
function InstructionItem:GetHeight()
|
|
return self.height
|
|
end
|