IEnumerator InitAssetList() { string url = AssetManagerSetting.FilesCsvForStreaming; WWW www = new WWW(url); yield return(www); assetList = AssetFileList.Read(AssetManagerSetting.AssetFileListPath); if (string.IsNullOrEmpty(www.error)) { string path, md5; using (StringReader stringReader = new StringReader(www.text)) { while (stringReader.Peek() >= 0) { string line = stringReader.ReadLine(); if (!string.IsNullOrEmpty(line)) { string[] seg = line.Split(';'); path = seg[0]; md5 = seg[1]; assetList.Add(path, md5); AssetManagerSetting.persistentAssetFileList.Remove(AssetManagerSetting.GetPlatformPath(path)); } } } } assetList.Save(AssetManagerSetting.AssetFileListPath); }
public static void GeneratorUpdateList(Version appVer) { string path = AssetManagerSetting.EditorUpdateAssetListPath; Debug.Log(path); PathUtil.CheckPath(path); if (appVer == null) { if (File.Exists(path)) { File.Delete(path); } File.Copy(AssetManagerSetting.EditorFileCsvForStreaming, path); return; } Debug.Log(appVer); AssetFileList app = AssetFileList.Read(AssetManagerSetting.EditorGetVersionFileListPath(appVer.ToString())); AssetFileList curr = AssetFileList.Read(AssetManagerSetting.EditorFileCsvForStreaming); AssetFileList diff = AssetFileList.DiffAssetFileList(app, curr); diff.Save(path); }
IEnumerator UpdateResource(string rootUrl) { // rootUrl = "http://www.ihaiu.com/StreamingAssets/" OnUpdateEnter(); //获取服务器端的file.csv OnState("获取服务器端的file.csv"); string updateAssetListUrl = AssetManagerSetting.GetServerFilesCsvURL(rootUrl); Debug.Log("UpdateAssetList URL: " + updateAssetListUrl); WWW www = new WWW(updateAssetListUrl); yield return(www); if (!string.IsNullOrEmpty(www.error)) { OnError("更新资源读取资源列表失败"); Debug.LogErrorFormat("更新资源读取资源列表失败 updateAssetListUrl={0}, www.error={1}", updateAssetListUrl, www.error); www.Dispose(); www = null; yield break; } AssetFileList updateAssetList = AssetFileList.Deserialize(www.text); www.Dispose(); www = null; //Debug.Log("count: " + files.Length + " text: " + filesText); OnState("读取" + AssetManagerSetting.AssetFileListPath); if (assetList == null) { assetList = AssetFileList.Read(AssetManagerSetting.AssetFileListPath); } List <AssetFile> diffs = AssetFileList.Diff(assetList, updateAssetList); AssetManagerSetting.persistentAssetFileList = AssetFileList.Read(AssetManagerSetting.PersistentAssetFileListPath); string path; //更新 int count = diffs.Count; for (int i = 0; i < count; i++) { AssetFile item = diffs[i]; path = AssetManagerSetting.GetPlatformPath(item.path); OnState("更新" + path); OnUpdateProgress((float)(i + 1) / (float)count); string url = rootUrl + path; www = new WWW(url); yield return(www); if (!string.IsNullOrEmpty(www.error)) { OnUpdateFailed(url); www.Dispose(); www = null; continue; } string localPath = AssetManagerSetting.RootPathPersistent + path; PathUtil.CheckPath(localPath, true); File.WriteAllBytes(localPath, www.bytes); www.Dispose(); www = null; assetList.Add(item); AssetManagerSetting.persistentAssetFileList.Add(path, item.md5); } yield return(new WaitForEndOfFrame()); assetList.Save(AssetManagerSetting.AssetFileListPath); AssetManagerSetting.persistentAssetFileList.Save(AssetManagerSetting.PersistentAssetFileListPath); // 更新完成 OnUpdateEnd(); }