static IEnumerator StartDownLoad() { Debug.Log("下载服务器文件到本地"); UpdateDateCallBack(HotUpdateStatusEnum.Updating, GetHotUpdateProgress(true, true, GetDownLoadFileProgress(0))); RecordTable hotupdateData = RecordManager.GetData(c_HotUpdateRecordName); for (int i = 0; i < s_downLoadList.Count; i++) { Hash128 md5Tmp = Hash128.Parse(hotupdateData.GetRecord(s_downLoadList[i].name, "null")); if (md5Tmp.Equals(s_downLoadList[i].md5)) { Debug.Log("文件已更新完毕 " + s_downLoadList[i].name); //该文件已更新完毕 UpdateDateCallBack(HotUpdateStatusEnum.Updating, GetHotUpdateProgress(true, true, GetDownLoadFileProgress(i))); } else { string downloadPath = s_resourcesFileDownLoadPath + s_downLoadList[i].name; WWW www = new WWW(downloadPath); yield return(www); if (www.error != null && www.error != "") { Debug.LogError("下载出错! " + downloadPath + " " + www.error); UpdateDateCallBack(HotUpdateStatusEnum.UpdateFail, GetHotUpdateProgress(true, true, GetDownLoadFileProgress(i))); yield break; } else { Debug.Log("下载成功! " + downloadPath); ResourceIOTool.CreateFile(PathTool.GetAssetsBundlePersistentPath() + "/" + s_downLoadList[i].name, www.bytes); RecordManager.SaveRecord(c_HotUpdateRecordName, s_downLoadList[i].name, s_downLoadList[i].md5.ToString()); UpdateDateCallBack(HotUpdateStatusEnum.Updating, GetHotUpdateProgress(true, true, GetDownLoadFileProgress(i))); } } } //保存版本信息 //保存文件信息 ResourceIOTool.CreateFile(PathTool.GetAssetsBundlePersistentPath() + c_versionFileName, s_versionByteCache); ResourceIOTool.CreateFile(PathTool.GetAssetsBundlePersistentPath() + AssetsManifestManager.c_ManifestFileName, s_ManifestByteCache); //从stream读取配置 RecordManager.SaveRecord(c_HotUpdateRecordName, c_useHotUpdateRecordKey, true); //重新生成资源配置 ResourcesConfigManager.LoadResourceConfig(); AssetsManifestManager.LoadAssetsManifest(); //延迟2秒卸载Bundle缓存,防止更新界面掉图(更新时间短时,卸载过快界面会掉图) //yield return new WaitForSeconds(2); ResourceManager.ReleaseAll(false); UpdateDateCallBack(HotUpdateStatusEnum.UpdateSuccess, 1); }