local ZUIPanelUpdate = ZUIPanelUpdate or {} ZUIPanelUpdate.textUpdateStateInfo = nil ZUIPanelUpdate.imageProgress = nil ZUIPanelUpdate.textTipsTitle = nil ZUIPanelUpdate.textTipsInfo = nil local function OnClickButtonYes() print("--> Click Yes ~") ZUIPanelUpdate.panelTips:SetActive(false) local eventDispatchCenter = require("Base/ZEventDispatchCenter.lua") eventDispatchCenter:DispatchEvent(eventDispatchCenter.EventType.UPDATE_RETRY) end local function OnClickButtonNo() print("--> Click No ~") ZUIPanelUpdate.panelTips:SetActive(false) CS.UnityEngine.Application.Quit() end function ZUIPanelUpdate.SetProgressPercent(percent) if percent <= 0 then percent = 0 end if percent >= 1 then percent = 1 end ZUIPanelUpdate.imageProgress:GetComponent("Image").fillAmount = percent; end function ZUIPanelUpdate.SetUpdateInfo(information) ZUIPanelUpdate.textUpdateStateInfo:GetComponent("Text").text = information end function ZUIPanelUpdate.SetTips(title, information) ZUIPanelUpdate.panelTips:SetActive(true) ZUIPanelUpdate.textTipsTitle:GetComponent("Text").text = title ZUIPanelUpdate.textTipsInfo:GetComponent("Text").text = information end function ZUIPanelUpdate.Awake() print("ZUIPanelUpdate Awake") --local prefabCanvasUpdate = CS.SFramework.SResourceManagerR.LoadResource("Prefabs/Canvas_Update.prefab") local prefabCanvasUpdate = LoadResource("Prefabs/Canvas_Update.prefab") local canvasUpdate = CS.UnityEngine.GameObject.Instantiate(prefabCanvasUpdate) ZUIPanelUpdate.canvasUpdate = canvasUpdate local panelUpdate = canvasUpdate.transform:Find("Panel_Update").gameObject local textInfo = panelUpdate.transform:Find("Text_Info").gameObject local imageProgress = panelUpdate.transform:Find("Image_Progress").gameObject local panelTips = canvasUpdate.transform:Find("Panel_Tips").gameObject local textTitle = panelTips.transform:Find("Text_Title").gameObject local tipsTextInfo = panelTips.transform:Find("Text_Info").gameObject panelTips:SetActive(false) ZUIPanelUpdate.panelTips = panelTips ZUIPanelUpdate.textUpdateStateInfo = textInfo ZUIPanelUpdate.imageProgress = imageProgress ZUIPanelUpdate.textTipsTitle = textTitle ZUIPanelUpdate.textTipsInfo = tipsTextInfo end function ZUIPanelUpdate.Start() print("ZUIPanelUpdate Start") local canvasUpdate = ZUIPanelUpdate.canvasUpdate local buttonYes = canvasUpdate.transform:Find("Panel_Tips/Button_Yes").gameObject buttonYes:GetComponent("Button").onClick:AddListener(OnClickButtonYes) local buttonNo = canvasUpdate.transform:Find("Panel_Tips/Button_No").gameObject buttonNo:GetComponent("Button").onClick:AddListener(OnClickButtonNo) ZUIPanelUpdate.RefreshInfo() local eventDispatchCenter = require("Base/ZEventDispatchCenter.lua") eventDispatchCenter:RegisterEvent(eventDispatchCenter.EventType.UPDATE_STATE_INFO, ZUIPanelUpdate.SetUpdateInfo) eventDispatchCenter:RegisterEvent(eventDispatchCenter.EventType.UPDATE_PROGRESS_PERCENT, ZUIPanelUpdate.SetProgressPercent) eventDispatchCenter:RegisterEvent(eventDispatchCenter.EventType.UPDATE_SHOW_TIPS, ZUIPanelUpdate.SetTips) end function ZUIPanelUpdate.OnDestroy() print("ZUIPanelUpdate.OnDestroy") local eventDispatchCenter = require("Base/ZEventDispatchCenter.lua") eventDispatchCenter:UnregisterEvent(eventDispatchCenter.EventType.UPDATE_STATE_INFO, ZUIPanelUpdate.SetUpdateInfo) eventDispatchCenter:UnregisterEvent(eventDispatchCenter.EventType.UPDATE_PROGRESS_PERCENT, ZUIPanelUpdate.SetProgressPercent) eventDispatchCenter:UnregisterEvent(eventDispatchCenter.EventType.UPDATE_SHOW_TIPS, ZUIPanelUpdate.SetTips) end function ZUIPanelUpdate.RefreshInfo() ZUIPanelUpdate.textTipsTitle:GetComponent("Text").text = "Update Tips" ZUIPanelUpdate.textTipsInfo:GetComponent("Text").text = "Prepare For Update." ZUIPanelUpdate.textUpdateStateInfo:GetComponent("Text").text = "Wait For Update." end return ZUIPanelUpdate