コード例 #1
0
        /// <summary>
        /// 异步初始化
        /// </summary>
        public IEnumerator InitializeAsync(bool simulationOnEditor)
        {
            if (simulationOnEditor)
            {
                yield break;
            }

            // 解析APP里的补丁清单
            string        filePath   = AssetPathHelper.MakeStreamingLoadPath(PatchDefine.PatchManifestFileName);
            string        url        = AssetPathHelper.ConvertToWWWPath(filePath);
            WebGetRequest downloader = new WebGetRequest(url);

            downloader.DownLoad();
            yield return(downloader);

            if (downloader.HasError())
            {
                downloader.ReportError();
                downloader.Dispose();
                throw new System.Exception($"Fatal error : Failed download file : {url}");
            }

            _patchManifest = PatchManifest.Deserialize(downloader.GetText());
            downloader.Dispose();
        }
コード例 #2
0
        public void SaveRemotePatchManifest(string content)
        {
            _localPatchManifest = PatchManifest.Deserialize(content);

            // 注意:这里会覆盖掉沙盒内的补丁清单文件
            MotionLog.Log("Save remote patch manifest.");
            string savePath = AssetPathHelper.MakePersistentLoadPath(PatchDefine.PatchManifestFileName);

            PatchManifest.Serialize(savePath, _localPatchManifest);
        }
コード例 #3
0
 public void ParseRemotePatchManifest(string content)
 {
     _localPatchManifest = PatchManifest.Deserialize(content);
 }
コード例 #4
0
        /// <summary>
        /// 异步初始化
        /// </summary>
        public IEnumerator InitializeAsync()
        {
            MotionLog.Log($"Beginning to initialize patch manager.");

            // 加载缓存
            _cache = PatchCache.LoadCache();

            // 检测沙盒被污染
            // 注意:在覆盖安装的时候,会保留沙盒目录里的文件,所以需要强制清空
            {
                // 如果是首次打开,记录APP版本号
                if (PatchHelper.CheckSandboxCacheFileExist() == false)
                {
                    _cache.CacheAppVersion = Application.version;
                    _cache.SaveCache();
                }
                else
                {
                    // 每次启动时比对APP版本号是否一致
                    if (_cache.CacheAppVersion != Application.version)
                    {
                        MotionLog.Warning($"Cache is dirty ! Cache version is {_cache.CacheAppVersion}, APP version is {Application.version}");
                        ClearCache();

                        // 重新写入最新的APP版本号
                        _cache.CacheAppVersion = Application.version;
                        _cache.SaveCache();
                    }
                }
            }

            // 加载APP内的补丁清单
            MotionLog.Log($"Load app patch manifest.");
            {
                string        filePath   = AssetPathHelper.MakeStreamingLoadPath(PatchDefine.PatchManifestFileName);
                string        url        = AssetPathHelper.ConvertToWWWPath(filePath);
                WebGetRequest downloader = new WebGetRequest(url);
                downloader.DownLoad();
                yield return(downloader);

                if (downloader.HasError())
                {
                    downloader.ReportError();
                    downloader.Dispose();
                    throw new System.Exception($"Fatal error : Failed download file : {url}");
                }

                // 解析补丁清单
                string jsonData = downloader.GetText();
                _appPatchManifest = PatchManifest.Deserialize(jsonData);
                downloader.Dispose();
            }

            // 加载沙盒内的补丁清单
            MotionLog.Log($"Load sandbox patch manifest.");
            if (PatchHelper.CheckSandboxPatchManifestFileExist())
            {
                string filePath = AssetPathHelper.MakePersistentLoadPath(PatchDefine.PatchManifestFileName);
                string jsonData = File.ReadAllText(filePath);
                _localPatchManifest = PatchManifest.Deserialize(jsonData);
            }
            else
            {
                _localPatchManifest = _appPatchManifest;
            }
        }