Exemple #1
0
        protected override void HandleProcedure()
        {
            string packageStr = (Resources.Load("Config/package") as TextAsset).text;

            UpdateSharedData.Instance.RemotePackage = JsonMapper.ToObject(packageStr);
            queue = new CoroutineQueue(100, UpdateSharedData.Instance.Processor.StartCoroutine);
            queue.OnBatchComplete += () =>
            {
                Debug.Log("Download Package Done!");
                PostProcedure();
            };
            List <string> temp = new List <string>();

            foreach (var item in UpdateSharedData.Instance.RemotePackage["packages"])
            {
                Debug.Log(item);
                temp.Add(item.ToString());
            }
            if (!Directory.Exists(EnvironmentVariables.UnzipAssetsRoot))
            {
                Directory.CreateDirectory(EnvironmentVariables.UnzipAssetsRoot);
            }
            if (!Directory.Exists(EnvironmentVariables.UnzipAssetsTemp))
            {
                Directory.CreateDirectory(EnvironmentVariables.UnzipAssetsTemp);
            }
            queue.RunBatch(temp.Select(packageUrl => GetPackageAndSave(packageUrl)));
        }
Exemple #2
0
 private void GetRemoteAssets()
 {
     if (IsAllDownloadCached())
     {
         HandleAfterDownloadSuccess();
     }
     ErrorList.Clear();
     // 协程请求数限制在100以下,因为:Curl error limit reached: 100 consecutive messages printed,由此推断UnityWebRequest的同时请求应该不超过这个值
     queue = new CoroutineQueue(100, UpdateSharedData.Instance.Processor.StartCoroutine);
     queue.OnBatchComplete += () => {
         bool isSuccess = true;
         // 检验下载完整性
         foreach (var item in UpdateSharedData.Instance.DownloadList)
         {
             if (!(item as AssetDownloadData).isSuccess)
             {
                 isSuccess = false;
                 break;
             }
         }
         if (isSuccess)
         {
             HandleAfterDownloadSuccess();
         }
         else
         {
             Debug.LogErrorFormat("have asset(s) download fail:{0}\n", ErrorList.Aggregate("", (retStr, data) => retStr += string.Format("{0},\n", data.localPath)));
             Debug.LogError("Stop @DownloadAssetsProcedure");
             OnError?.Invoke();
         }
     };
     queue.RunBatch(UpdateSharedData.Instance.DownloadList.Select(asset => GetUpdateFileAndSave(asset)));
 }