Example #1
0
 private static string GetCacheDataFilePath()
 {
     return(PathHelper.MakePersistentLoadPath("CacheData.bytes"));
 }
        public void Update()
        {
            if (IsDone())
            {
                return;
            }

            if (_steps == ESteps.LoadStaticVersion)
            {
                YooLogger.Log($"Load application static version.");
                string filePath = PathHelper.MakeStreamingLoadPath(YooAssetSettings.VersionFileName);
                string url      = PathHelper.ConvertToWWWPath(filePath);
                _downloader1 = new UnityWebDataRequester();
                _downloader1.SendRequest(url);
                _steps = ESteps.CheckStaticVersion;
            }

            if (_steps == ESteps.CheckStaticVersion)
            {
                if (_downloader1.IsDone() == false)
                {
                    return;
                }

                if (_downloader1.HasError())
                {
                    Error  = _downloader1.GetError();
                    _steps = ESteps.Failed;
                }
                else
                {
                    _staticVersion = int.Parse(_downloader1.GetText());
                    _steps         = ESteps.LoadAppManifest;
                }
                _downloader1.Dispose();
            }

            if (_steps == ESteps.LoadAppManifest)
            {
                YooLogger.Log($"Load application patch manifest.");
                string filePath = PathHelper.MakeStreamingLoadPath(YooAssetSettingsData.GetPatchManifestFileName(_staticVersion));
                string url      = PathHelper.ConvertToWWWPath(filePath);
                _downloader2 = new UnityWebDataRequester();
                _downloader2.SendRequest(url);
                _steps = ESteps.CheckAppManifest;
            }

            if (_steps == ESteps.CheckAppManifest)
            {
                if (_downloader2.IsDone() == false)
                {
                    return;
                }

                if (_downloader2.HasError())
                {
                    Error  = _downloader2.GetError();
                    _steps = ESteps.Failed;
                }
                else
                {
                    // 解析APP里的补丁清单
                    Result = PatchManifest.Deserialize(_downloader2.GetText());
                    _steps = ESteps.Succeed;
                }
                _downloader2.Dispose();
            }
        }