123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- 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<CheckSystem>();
- 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; }
- /// <summary>
- /// 手动升级模式还是自动
- /// 手动模式对于Ignor的版本也会去升级
- /// 自动模式会忽略Ingnor的版本
- /// </summary>
- 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<bool, bool, bool> CheckFinishCallBack) {
- Debug.Log("RegisterCheckFinishCallBack");
- CheckSystemProcessData.CheckFinishCallBack += CheckFinishCallBack;
- }
- public static void UnRegisterCheckFinishCallBack(Action<bool, bool, bool> 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();
- }
- }
- }
- }
|