static async ETTask RefreshProgress(this UIUpdateView self, DownloadComponent downloadTool) { while (self.m_needdownloadinfo.Count != self.overCount) { self.SetProgress(downloadTool.GetProress()); await TimerComponent.Instance.WaitAsync(10); } }
//资源更新检查,并根据版本来修改资源cdn地址 public static async ETTask <bool> CheckResUpdate(this UIUpdateView self) { var app_channel = PlatformUtil.GetAppChannel(); var engine_ver = AssetBundleConfig.Instance.EngineVer; var maxVer = ServerConfigComponent.Instance.FindMaxUpdateResVer(engine_ver, app_channel); if (string.IsNullOrEmpty(maxVer)) { Log.Info("CheckResUpdate No Max Ver EngineVer = " + engine_ver + " app_channel " + app_channel); return(false); } var res_ver = AssetBundleConfig.Instance.ResVer; var flag = VersionCompare.Compare(res_ver, maxVer); Log.Info("CheckResUpdate ResVer:{0} maxVer:{1}", res_ver, maxVer); if (flag >= 0) { Log.Info("CheckResUpdate ResVer is Most Max Version, so return; flag = " + flag); return(false); } // 编辑器下不能测试热更,但可以测试下载。 if (Define.IsEditor) { return(false); } //找到最新版本,则设置当前资源存放的cdn地址 var url = ServerConfigComponent.Instance.GetUpdateCdnResUrlByVersion(maxVer); self.m_rescdn_url = url; Log.Info("CheckResUpdate res_cdn_url is " + url); AssetBundleMgr.GetInstance().SetAddressableRemoteResCdnUrl(self.m_rescdn_url); //等一会等addressables的Update回调执行完 await TimerComponent.Instance.WaitAsync(1); //检查更新版本 Log.Info("begin CheckCatalogUpdates"); var catalog = await self.CheckCatalogUpdates(); Log.Info("CheckResUpdate CataLog = " + catalog); //1、先更新catalogs if (!string.IsNullOrEmpty(catalog)) { Log.Info("begin UpdateCatalogs"); var res = await self.UpdateCatalogs(catalog); if (!res) { return(false); } Log.Info("CoCheckResUpdate Update Catalog Success"); } Log.Info("begin GetDownloadSize"); //获取需要更新的大小 var size = await self.GetDownloadSize(); //提示给用户 Log.Info("downloadSize " + size); double size_mb = size / (1024f * 1024f); Log.Info("CheckResUpdate res size_mb is " + size_mb);//不屏蔽 if (size_mb > 0 && size_mb < 0.01) { size_mb = 0.01; } var ct = I18NComponent.Instance.I18NGetParamText("Update_Info", size_mb.ToString("0.00")); var btnState = await self.ShowMsgBoxView(ct, "Global_Btn_Confirm", "Btn_Exit"); if (btnState == self.BTN_CANCEL) { if (self.force_update) { GameUtility.Quit(); return(false); } return(true); } //开始进行更新 self.last_progress = 0; self.SetProgress(0); //2、更新资源 var merge_mode_union = 1; var needdownloadinfo = await self.CheckUpdateContent(merge_mode_union); Log.Info("needdownloadinfo count: ", needdownloadinfo.Count); self.m_needdownloadinfo = SortDownloadInfo(needdownloadinfo); Log.Info("CheckResUpdate DownloadContent begin"); bool result = await self.DownloadContent(); if (!result) { return(false); } Log.Info("CheckResUpdate DownloadContent Success"); return(true); }