//根据base包比较判断是否需要更新 private IEnumerator UF_Upgrade(DelegateMethod callback) { //忽略版本更新检查 if (IngoreResVersionCheck) { callback(STATE_SUCCESS); yield break; } //先检查源站文件是否能正常下载,否则去CDN获取文件 string urlVersionFile = UF_GetUpgradeFileURL(GlobalSettings.UrlRawAssetsUpgrade); UF_LogInfo("URL Raw Res Version:" + urlVersionFile); //获取资源版本列表 //检查是否与更新包 WWW wwwResVersionFile = new WWW(urlVersionFile); yield return(wwwResVersionFile); if (!string.IsNullOrEmpty(wwwResVersionFile.error)) { UF_LogError(string.Format("Upgrade -> Raw wwwResVersionFile error[{0}] \n errorinfo:[{1}]", wwwResVersionFile.url, wwwResVersionFile.error)); wwwResVersionFile.Dispose(); UF_LogInfo("Upgrade -> Try to download version file from CDN"); urlVersionFile = UF_GetUpgradeFileURL(GlobalSettings.UrlAssetsUpgrade); UF_LogInfo("URL CDN Res Version:" + urlVersionFile); wwwResVersionFile = new WWW(urlVersionFile); yield return(wwwResVersionFile); } if (!string.IsNullOrEmpty(wwwResVersionFile.error)) { UF_LogError(string.Format("wwwResVersionFile error[{0}] \n errorinfo:[{1}]", wwwResVersionFile.url, wwwResVersionFile.error)); //无法获取更新文件,是否跳过更新 AlertDialog.UF_ShowOkCancel(GlobalText.LAN_WARNING, GlobalText.LAN_CANCLE, GlobalText.LAN_CONFIRM, GlobalText.LAN_ERROR_CHECK_UPGRADE, (e) => { callback(STATE_ERROR); }, (e) => { callback(STATE_SUCCESS); }); yield break; } string txtVersionFile = wwwResVersionFile.text; wwwResVersionFile.Dispose(); //判断更新包大小情况 m_LstUpdateFileInfo.Clear(); webUpgradInfo = txtVersionFile; Debugger.UF_LogTag("version", string.Format("Upgrade:{0} \n {1}", urlVersionFile, txtVersionFile)); UF_WrapUpdateList(txtVersionFile, localAssetVersion, m_LstUpdateFileInfo); CheckPointManager.UF_Send(7); //没有需要更新的更新包则跟新完成 if (m_LstUpdateFileInfo.Count == 0) { callback(STATE_SUCCESS); yield break; } else { //更新包大小比较建议 float size = 0; for (int k = 0; k < m_LstUpdateFileInfo.Count; k++) { size += m_LstUpdateFileInfo[k].size; } size = (int)(size / (float)(1024 * 1024)); DelegateMethod DelegateExctureUpdate = delegate(object param) { m_UpgradeFiles.UF_Upgrade(m_LstUpdateFileInfo, (e) => { if (!(bool)e) { UF_ShowMessageBox(GlobalText.LAN_ERROR_CHECK_UPGRADE, GlobalText.LAN_CONFIRM, (k) => { //更新失败 callback(STATE_ERROR); }); } else { callback(STATE_SUCCESS); } }); }; //wifi 下载提示 // if (size > SizeUpgradeAdvice) { // ShowMessageBox(string.Format(AppLanguages.LValue("LAN_UPDATE_TIPS"), size), AppLanguages.LValue("LAN_START_UPDATE"), DelegateExctureUpdate); // } // else { DelegateExctureUpdate(null); // } } }
private void UF_ShowMessageBox(string info, string btnInfo, DelegateMethod onClick = null) { AlertDialog.UF_Show(GlobalText.LAN_WARNING, btnInfo, info, onClick); }