using System.Collections; using UniFramework.Pooling; using UnityEngine; using YooAsset; namespace GFGGame { public class HotUpdateDriver: MonoBehaviour { private void Awake() { //UniFramework // 初始化对象池系统 UniPooling.Initalize(); //Litjson LitJson.UnityTypeBindings.Register(); //ET ETManager.Instance.Init(); //Game OperationSystem.Initialize(); GameController.Start(); } private void Update() { OperationSystem.Update(); CheckExitAlert(); } private void OnDestroy() { OperationSystem.DestroyAll(); } private void OnApplicationQuit() { SQLiteHelper.Instance.CloseConnection(true); } private void CheckExitAlert() { if (Input.GetKeyDown(KeyCode.Escape) || Input.GetKeyDown(KeyCode.Home)) { QDManager.Exit(); } } private float pauseTime; private void OnApplicationPause(bool pause) { if(pause) { pauseTime = Time.realtimeSinceStartup; } else { if(Time.realtimeSinceStartup - pauseTime > 300 || LauncherConfig.netType == LauncherConfig.EnumNetType.LOCAL) { StartCoroutine(CheckVersion(VersionController.DefaultPackage)); } } } private IEnumerator CheckVersion(string packageName) { var package = YooAssets.GetPackage(packageName); string oldVersion = package.GetPackageVersion(); var operation = package.UpdatePackageVersionAsync(); yield return operation; if (operation.Status == EOperationStatus.Succeed) { VersionController.Instance.PackageVersion = operation.PackageVersion; LogUtil.LogDev($"版本对比: {oldVersion} {operation.PackageVersion}"); if(!operation.PackageVersion.Equals(oldVersion)) { AlertSystem.Show("游戏已有更新,您可以立即重启游戏获取最佳游戏体验,也可以稍后重启更新。") .SetLeftButton(true, "稍后更新") .SetRightButton(true, "重启游戏", (obj)=> { Application.Quit(); }); } } } } }