public static void StartLoadResource(CallBack completeCallBack) { AssetData[] ads = ResourcesManager.LoadAssetsByName("AssetBundleInfo"); if (ads.Length > 0) { TextAsset tx = ads[0].asset as TextAsset; Dictionary <string, object> tempDic = InternalConfigManager.LoadData(tx.text); string s = tempDic["preLoadResPaths"].ToString(); List <string> pathNames = tempDic["preLoadResPaths"] as List <string>; int count = pathNames.Count; ResourcesManager.LoadManyAssetAsyncByName(pathNames, (num) => { int left = count - num + 1; //Debug.LogError("Left :" + num); if (progressCallBack != null) { progressCallBack(count, count - num); } if (showContentCallBack != null) { string ss = "Preload(" + (count - num) + " / " + count + ")"; showContentCallBack(ss); } }, completeCallBack); } else { if (completeCallBack != null) { completeCallBack(); } } }
static IEnumerator Updating(CallBack completCalback) { //加载沙河路径下的AssetBundleInfo string assetBundleInfoPer = FileUtils.LoadTextFileByPath(PathDir + "/AssetBundleInfo.txt"); string assetBundleInfoStream = ""; string tempAbInfoPath = OtherUtils.GetWWWLoadPath(Application.streamingAssetsPath + "/AssetBundleInfo.txt"); //加载StreamAssets下的AssetBundleInfo yield return(FileUtils.LoadTxtFileIEnumerator(tempAbInfoPath, (data) => { assetBundleInfoStream = data; })); string bundleVersion = ""; int updatePackVersion = 0; Debug.Log("加载StreamAssets下的AssetBundleInfo :" + assetBundleInfoStream); Dictionary <string, object> tempDic = InternalConfigManager.LoadData(assetBundleInfoStream); bundleVersion = tempDic["bundleVersion"].ToString(); if (!string.IsNullOrEmpty(assetBundleInfoPer)) { Dictionary <string, object> dic = InternalConfigManager.LoadData(assetBundleInfoPer); string streamver1 = dic["updatePackVersion"].ToString(); string bunStreamVer1 = dic["bundleVersion"].ToString(); if (bundleVersion == bunStreamVer1) { updatePackVersion = int.Parse(streamver1.Split('-')[2]); } } Debug.Log("updatePackVersion: " + updatePackVersion); string updatePackData = ""; showContentCallBack("Download UpdatePackData"); //服务器下载updatePackData yield return(FileUtils.LoadTxtFileIEnumerator(serverPath + "/" + platform + "/updatePackData.txt", (data) => { updatePackData = data; })); List <string> upVerList = new List <string>(); Debug.Log("服务器下载updatePackData :" + updatePackData); if (!string.IsNullOrEmpty(updatePackData)) { Dictionary <string, object> updatePackDataDic = InternalConfigManager.LoadData(updatePackData); if (updatePackDataDic.ContainsKey(bundleVersion)) { List <string> upVerListTemp = (List <string>)updatePackDataDic[bundleVersion]; for (int i = 0; i < upVerListTemp.Count; i++) { int temp = int.Parse(upVerListTemp[i].Split('-')[2]); if (temp > updatePackVersion) { Debug.Log("updatePackVersion : " + updatePackVersion + " upVerListTemp[i]:" + upVerListTemp[i]); upVerList.Add(upVerListTemp[i]); } } } } for (int i = 0; i < upVerList.Count; i++) { int count = upVerList.Count; string serverFilePath = serverPath + "/" + platform + "/" + bundleVersion + "/" + upVerList[i] + "/" + upVerList[i] + ".zip"; string fileTempSavePath = PathDir + "/" + upVerList[i] + ".zip"; showContentCallBack("Download Update Pack:" + upVerList[i]); progressCallBack(count, i + 1); Debug.Log("更新包:" + serverFilePath); yield return(DownloadUpdateZipFile(serverFilePath, fileTempSavePath)); } yield return(new WaitForEndOfFrame()); Debug.Log("更新完成"); if (completCalback != null) { completCalback(); } }