using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using SC; using LitJson; namespace SC.Tools.UpdateAPKSystem.CheckSystem { public class CheckSystem : SystemBase { private static CheckSystem Instant; public static CheckSystem getInstant { get { if (Instant == null) { Debug.Log("[CheckSystem=====================================]: " + "Instantiate Start"); Instant = Instantiate((GameObject)Resources.Load("Prefabs/CheckSystem")). GetComponent(); Debug.Log("[" + Instant.GetType().ToString() + "]: " + "Instantiate Finish"); } return Instant; } } public CheckSystemData CheckSystemDataSubSystem { get; set; } public CheckSystemGetData CheckSystemGetDataSubSystem { get; set; } public CheckSystemProcessData CheckSystemProcessDataSubSystem { get; set; } public CanvasUI CanvasUI { get; set; } /// /// 手动升级模式还是自动 /// 手动模式对于Ignor的版本也会去升级 /// 自动模式会忽略Ingnor的版本 /// public bool isManualMode { get; set; } public override void Awake() { base.Awake(); WebRequestServerForCheckSystem.RegisterGetDataFromWebRequestFailedCallBack(FailCallBack); WebRequestServerForCheckSystem.RegisterGetDataFromWebRequestErrorCallBack(ErrorCallBack); WebRequestServerForCheckSystem.RegisterDataFromWebRequestErrorCallBack(DataErrorCallBack); isManualMode = false; AddSubSystem(CheckSystemDataSubSystem = CheckSystemData.getInstant); AddSubSystem(CheckSystemGetDataSubSystem = new CheckSystemGetData()); AddSubSystem(CheckSystemProcessDataSubSystem = new CheckSystemProcessData()); AddSubSystem(CanvasUI = CanvasUI.getInstant); } public override void SystemStart() { base.SystemStart(); ///当手动打开版本检测时,需要显示Canvas面板,当后台打开版本检测时,不需要显示Canvas面板 if (isManualMode == false) { CanvasUI.SystemStop(); } } public override void OnDestroy() { base.OnDestroy(); WebRequestServerForCheckSystem.UnRegisterGetDataFromWebRequestFailedCallBack(FailCallBack); WebRequestServerForCheckSystem.UnRegisterGetDataFromWebRequestErrorCallBack(ErrorCallBack); WebRequestServerForCheckSystem.UnRegisterDataFromWebRequestErrorCallBack(DataErrorCallBack); } public static void RegisterCheckFinishCallBack(Action CheckFinishCallBack) { Debug.Log("RegisterCheckFinishCallBack"); CheckSystemProcessData.CheckFinishCallBack += CheckFinishCallBack; } public static void UnRegisterCheckFinishCallBack(Action CheckFinishCallBack) { Debug.Log("UnRegisterCheckFinishCallBack"); CheckSystemProcessData.CheckFinishCallBack -= CheckFinishCallBack; } void FailCallBack(JsonData jsonData) { Debug.Log("[" + GetType().ToString() + "]: " + "FailCallBack"); ///后台检测时 失败不显示Canvas if (isManualMode == true) { CanvasUI.SystemStart(); } else { UpdateAPKSystem.getInstant.SystemStop(); } } void ErrorCallBack(JsonData jsonData) { Debug.Log("[" + GetType().ToString() + "]: " + "ErrorCallBack"); ///后台检测时 出错不显示Canvas if (isManualMode == true) { CanvasUI.SystemStart(); } else { UpdateAPKSystem.getInstant.SystemStop(); } } void DataErrorCallBack(JsonData jsonData) { Debug.Log("[" + GetType().ToString() + "]: " + "DataErrorCallBack"); ///后台检测时 出错不显示Canvas if (isManualMode == true) { CanvasUI.SystemStart(); } else { UpdateAPKSystem.getInstant.SystemStop(); } } } }