UIGuideView.lua 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. local UIGuideView = require("UIGuide/UIGuideView_Generate")
  2. local TransparentColor = {0.18,0.18,0.18, 0.3}
  3. local BlackColor = {0.3,0.3, 0.3, 1}
  4. function UIGuideView:OnAwake(data)
  5. self.controller = require("UIGuide/UIGuideCtr"):new()
  6. self.controller:Init(self)
  7. self.controller:SetData(data)
  8. end
  9. function UIGuideView:AddEventListener()
  10. self.uiBase:AddUIEventHandlerClickListener(self.uIEventHandler, function (go)
  11. self:UIClose()
  12. end)
  13. end
  14. function UIGuideView:FillContent(data, uiBase)
  15. self.uiBase = uiBase
  16. local gameObject = self.uiBase:GetRoot()
  17. if gameObject ~= nil then
  18. self.gameObject = gameObject
  19. self.transform = gameObject.transform
  20. end
  21. self:InitGenerate(self.transform, data)
  22. self:Init()
  23. end
  24. function UIGuideView:Init()
  25. local data = self.controller:GetData()
  26. local type = data.type
  27. local pos = data.pos
  28. local targetHeight = data.height
  29. if type == Enum.UIGuideSource.StageGoal then
  30. self.bg:SetActive(false)
  31. CommonUtil.SetGraphicColor(self.bg.image, TransparentColor)
  32. self.arrow_bg:SetActive(true)
  33. self.arrow_bg.transform.position = pos
  34. local height = self.arrow.rectTransform.sizeDelta.y
  35. self.arrow_bg.rectTransform.anchoredPosition = self.arrow_bg.rectTransform.anchoredPosition + Vector2.up * (targetHeight + height) * 0.5
  36. end
  37. end
  38. function UIGuideView:RemoveEventListener()
  39. ManagerContainer.LuaEventMgr:Unregister(self.uiData.name)
  40. end
  41. function UIGuideView:AddUIEventListener()
  42. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name)
  43. end
  44. function UIGuideView:OnHide()
  45. end
  46. function UIGuideView:OnShow(data)
  47. self.controller:SetData(data)
  48. self:Init()
  49. end
  50. function UIGuideView:OnClose()
  51. end
  52. function UIGuideView:OnDispose()
  53. self.uIEventHandler:RemoveListener()
  54. end
  55. return UIGuideView