ZUIPanelDialogConfirm.lua.txt 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. local ZUIDialogConfirmPanel = {}
  2. local function CloseDialogUI()
  3. require("Base/UIHelper.lua"):CloseUI("UI/Public/ZUIPanelDialogConfirm.lua")
  4. end
  5. function ZUIDialogConfirmPanel.SetInfo(tips, confirmFunction, cancelFunction)
  6. local rootPanel = ZUIDialogConfirmPanel.rootPanel
  7. local textTips = rootPanel.transform:Find("Text_Tips").gameObject
  8. textTips:GetComponent("Text").text = tips
  9. local buttonConfirm = rootPanel.transform:Find("Button_OK").gameObject
  10. buttonConfirm:GetComponent("Button").onClick:AddListener(function()
  11. print("ZUIDialogConfirmPanel.OnClickConfirm")
  12. if confirmFunction ~= nil then confirmFunction() end
  13. CloseDialogUI()
  14. end)
  15. local buttonCancel = rootPanel.transform:Find("Button_Cancel").gameObject
  16. buttonCancel:GetComponent("Button").onClick:AddListener(function()
  17. print("ZUIDialogConfirmPanel.OnClickCancel")
  18. if cancelFunction ~= nil then cancelFunction() end
  19. CloseDialogUI()
  20. end)
  21. end
  22. local function MeetingClosedNotify()
  23. CloseDialogUI()
  24. end
  25. local function RegisterEvent()
  26. local eventManager = require("Base/ZEventDispatchCenter.lua")
  27. eventManager:RegisterEvent(eventManager.EventType.CLOSE_ALL_PAGE, MeetingClosedNotify)
  28. end
  29. local function UnregisterEvent()
  30. local eventManager = require("Base/ZEventDispatchCenter.lua")
  31. eventManager:UnregisterEvent(eventManager.EventType.CLOSE_ALL_PAGE, MeetingClosedNotify)
  32. end
  33. function ZUIDialogConfirmPanel.Awake(luaRoot)
  34. ZUIDialogConfirmPanel.luaRoot = luaRoot
  35. local canvas = CS.UnityEngine.GameObject.Find("Canvas")
  36. ZUIDialogConfirmPanel._rootCanvas = canvas
  37. local prefabPanel = LoadResource("Prefabs/UI/Public/ZUIDialogConfirmPanel.prefab")
  38. local rootPanel = CS.UnityEngine.GameObject.Instantiate(prefabPanel, ZUIDialogConfirmPanel._rootCanvas.transform)
  39. rootPanel.name = "ZUIDialogConfirmPanel"
  40. ZUIDialogConfirmPanel.rootPanel = rootPanel
  41. end
  42. function ZUIDialogConfirmPanel.Start()
  43. RegisterEvent()
  44. end
  45. function ZUIDialogConfirmPanel.OnDestroy()
  46. UnregisterEvent()
  47. CS.UnityEngine.GameObject.Destroy(ZUIDialogConfirmPanel.rootPanel)
  48. print("ZUIDialogConfirmPanel.OnDestroy ... ...")
  49. end
  50. return ZUIDialogConfirmPanel