using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using SC; using SC.Tools.UpdateAPKSystem.CheckSystem; using SC.Tools.UpdateAPKSystem.UpdateSystem; namespace SC.Tools.UpdateAPKSystem { public class UpdateAPKSystem : SystemBase { public CheckSystem.CheckSystem checkSystem; public UpdateSystem.UpdateSystem updateSystem; public AndroidPluginManifest androidPluginManifest; public AndroidPluginUpdateAPK androidPluginUpdateAPK; private static UpdateAPKSystem mInstant; public static UpdateAPKSystem getInstant { get { if (mInstant == null) { Debug.Log("[UpdateAPKSystem=====================================]: " + "Instantiate Start"); mInstant = Instantiate((GameObject)Resources.Load("Prefabs/UpdataAPKSystem")). GetComponent(); Debug.Log("[" + mInstant.GetType().ToString() + "]: " + "Instantiate Finish"); } return mInstant; } } public override void Awake() { if (mInstant) { DestroyImmediate(gameObject); return; } base.Awake(); mInstant = this; DontDestroyOnLoad(gameObject); CheckSystem.CheckSystem.RegisterCheckFinishCallBack(CheckFinishCallBack); AddSubSystem(androidPluginUpdateAPK = AndroidPluginUpdateAPK.getInstant); AddSubSystem(androidPluginManifest = AndroidPluginManifest.getInstant); AddSubSystem(checkSystem = CheckSystem.CheckSystem.getInstant); AddSubSystem(updateSystem = UpdateSystem.UpdateSystem.getInstant); } public override void OnDestroy() { base.OnDestroy(); CheckSystem.CheckSystem.UnRegisterCheckFinishCallBack(CheckFinishCallBack); } void CheckFinishCallBack(bool hasNewVersion, bool isForceUpdate,bool isIgnorUpdate) { Debug.Log("[" + GetType().ToString() + "]: " + "CheckFinishCallBack:hasNewVersion:"+ hasNewVersion+" isForceUpdate:"+ isForceUpdate + " isIgnorUpdate:" + isIgnorUpdate+" isManualMode:"+ checkSystem.isManualMode); if (hasNewVersion == false) { Debug.Log("[" + GetType().ToString() + "]: " + "hasNewVersion == false ,CloseUpdateAPKSystem"); SystemStop(); return; } if (isIgnorUpdate && checkSystem.isManualMode==false) { Debug.Log("[" + GetType().ToString() + "]: " + "isIgnorUpdate == true ,CloseUpdateAPKSystem"); SystemStop(); return; } Debug.Log("[" + GetType().ToString() + "]: " + "Go To UpdateSystem !"); checkSystem.SystemStop(); updateSystem.SystemStart(); return; } ///后台打开版本检测API,不需要显示Canvas面板 public override void SystemStart() { base.SystemStart(); updateSystem.SystemStop(); } public override void SystemStop() { base.SystemStop(); checkSystem.isManualMode = false; } /// /// 当手动打开版本检测API,需要显示Canvas面板 /// public void Run() { checkSystem.isManualMode = true; SystemStart(); } /// /// 后台自动运行时API,检测有问题不显示Canvas面板,除有更新出现才会显示Canvas面板 /// public void RunSilent() { checkSystem.isManualMode = false; SystemStart(); } /// /// 停用检测API /// public void Stop() { SystemStop(); } } }