//资源更新检查,并根据版本来修改资源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); }
async static ETTask <bool> CheckAppUpdate(this UIUpdateView self) { var app_channel = PlatformUtil.GetAppChannel(); var channel_app_update_list = ServerConfigComponent.Instance.GetAppUpdateListByChannel(app_channel); if (channel_app_update_list == null || channel_app_update_list.app_ver == null) { Log.Info("CheckAppUpdate channel_app_update_list or app_ver is nil, so return"); return(false); } var maxVer = ServerConfigComponent.Instance.FindMaxUpdateAppVer(app_channel); if (string.IsNullOrEmpty(maxVer)) { Log.Info("CheckAppUpdate maxVer is nil"); return(false); } var app_ver = Application.version; var flag = VersionCompare.Compare(app_ver, maxVer); Log.Info(string.Format("CoCheckAppUpdate AppVer:{0} maxVer:{1}", app_ver, maxVer)); if (flag >= 0) { Log.Info("CheckAppUpdate AppVer is Most Max Version, so return; flag = " + flag); return(false); } var app_url = channel_app_update_list.app_url; var verInfo = channel_app_update_list.app_ver[app_ver]; Log.Info("CheckAppUpdate app_url = " + app_url); self.force_update = Define.ForceUpdate; if (Define.ForceUpdate)//默认强更 { if (verInfo != null && verInfo.force_update == 0) { self.force_update = false; } } else { if (verInfo != null && verInfo.force_update != 0) { self.force_update = true; } } var cancelBtnText = self.force_update ? "Btn_Exit" : "Btn_Enter_Game"; var content_updata = self.force_update ? "Update_ReDownload" : "Update_SuDownload"; var btnState = await self.ShowMsgBoxView(content_updata, "Global_Btn_Confirm", cancelBtnText); if (btnState == self.BTN_CONFIRM) { GameUtility.OpenURL(app_url); //为了防止切换到网页后回来进入了游戏,所以这里需要继续进入该流程 return(await self.CheckAppUpdate()); } else if (self.force_update) { Log.Info("CheckAppUpdate Need Force Update And User Choose Exit Game!"); GameUtility.Quit(); return(true); } return(false); }