IEnumerator OnExtractResource() { if (Directory.Exists(PathTools.DataPath)) { Directory.Delete(PathTools.DataPath, true); } Directory.CreateDirectory(PathTools.DataPath); yield return(StartCoroutine(OnExtractFile(resourceFile))); localResourceData = new ResourceData(); localResourceData.InitDataFromFile(PathTools.DataPath + resourceFile); int dataRow = localResourceData.GetDataRow(); string fullName = string.Empty; for (int i = 1; i <= dataRow; ++i) { fullName = localResourceData.GetBundleFullName(i); yield return(StartCoroutine(OnExtractFile(fullName))); if (decompressUpdate != null) { decompressUpdate(i, dataRow); } } //释放完成,开始启动更新资源 CheckUpdateResource(); }
IEnumerator CheckResourceFile() { WWW www = new WWW(UpdateConfig.Instance.serverUrl + resourceFile); yield return(www); if (!string.IsNullOrEmpty(www.error)) { Debug.Log(www.error); EndUpdateResource(); yield break; } remoteResult = www.text; remoteResourceData = new ResourceData(); remoteResourceData.InitData(remoteResult); localResourceData = new ResourceData(); localResourceData.InitDataFromFile(PathTools.DataPath + resourceFile); downloadList.Clear(); int dataRow = remoteResourceData.GetDataRow(); for (int i = 1; i <= dataRow; ++i) { string bundleName = remoteResourceData.GetBundleName(i); string remoteMd5 = remoteResourceData.GetMd5(i); string localMd5 = localResourceData.GetMd5ByBundleName(bundleName); //Debug.Log(remoteMd5 + " : " + localMd5); if (remoteMd5.CompareTo(localMd5) != 0) { downloadList.Add(bundleName); } } downloadFileIndex = 0; downloadRetryCount = 0; totalFileCount = downloadList.Count; finishFileSize = 0; GetTotalFileSize(); DownloadNextFile(); }