源战役客户端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 regels
1.6 KiB

1 maand geleden
  1. InstructionItem = InstructionItem or BaseClass(BaseItem)
  2. function InstructionItem:__init()
  3. self.base_file = "common"
  4. self.layout_file = "instructionItem"
  5. self.height = 0
  6. self:Load()
  7. end
  8. function InstructionItem:Load_callback()
  9. self.titleText = self:GetChild("titleText"):GetComponent(typeof(TMPro.TextMeshProUGUI))
  10. self.title_di = self:GetChild("title_di")
  11. self.title_di_obj = self:GetChild("title_di").gameObject
  12. self.line_obj = self:GetChild("line").gameObject
  13. self.contentText = self:GetChild("contentText")
  14. self.contentText_t = self:GetChild("contentText"):GetComponent(typeof(TMPro.TextMeshProUGUI))
  15. end
  16. function InstructionItem:SetData(vo)
  17. if vo then
  18. if vo.itemTitle=="" then --无需子标题
  19. self.title_di_obj:SetActive(false)
  20. self.line_obj:SetActive(false)
  21. self.titleText.text = ""
  22. self.contentText.transform.anchoredPosition = Vector2(25, 0)
  23. else
  24. self.title_di_obj:SetActive(true)
  25. self.line_obj:SetActive(true)
  26. self.titleText.text = vo.itemTitle
  27. self.contentText.transform.anchoredPosition = Vector2(25, -45)
  28. end
  29. self.contentText_t.text = vo.content
  30. SetLocalPositionX(self.title_di,GetLocalPositionX(self.titleText.transform)-(self.titleText.preferredWidth/2)-16)
  31. --先把宽度设置好再计算文本高度,否则会导致计算错误
  32. SetSizeDeltaX(self.contentText.transform,520)
  33. self.height = self.contentText_t.preferredHeight + 10
  34. self.contentText.sizeDelta = Vector2(520,self.height)
  35. -- self.height = self.height + 32
  36. self.height = self.height + 60
  37. end
  38. end
  39. function InstructionItem:GetHeight()
  40. return self.height
  41. end