public static string GetPackageName(string path) { string[] model = path.ToLower().Split(RGResource.PATH_SEPARATOR); // 包路径 string packageUrl = ""; if (model.Length > 0) { if (model[0].Equals("effect")) { //effect packageUrl = "effect"; } else if (model[0].Equals("prefabs")) { // prefabs packageUrl = "prefabs"; } RGLog.DebugResLoad("<color=yellow>Package Name = " + packageUrl + "</color>"); return(packageUrl.ToLower()); } RGLog.DebugError("GetPackagePath Error ! Path is Empty"); return(string.Empty); }
// 永久 bundle public static void LoadForeverBundleAsync(string path, Action <AssetBundle, LoadEventData> loadComplete, params object[] data) { if (string.IsNullOrEmpty(path)) { RGLog.Error("<color=red> 加载 永久 Bundle 资源路径为空!!!</color>"); if (loadComplete != null) { loadComplete.Invoke(null, ParseFrom(data)); } return; } if (data != null) { object[] tempData = new object[data.Length + 1]; tempData.SetValue(LOAD_BUNDLE_FOREVER_FLAG, 0); for (int i = 0; i < data.Length; i++) { tempData.SetValue(data[i], i + 1); } LoadAsync <AssetBundle>(path, "", loadComplete, ParseFrom(tempData)); } else { object[] tempData = new object[1]; tempData.SetValue(LOAD_BUNDLE_FOREVER_FLAG, 0); LoadAsync <AssetBundle>(path, "", loadComplete, ParseFrom(tempData)); } }
// 自动检查卸载点资源包 // UI 资源暂时不卸载 // 已经加载但是还有缓存资源没有加载点不进行卸载 // 正在加载点资源也不进行卸载 private static void CheckUnloadPackage() { List <string> unloadPackageList = new List <string>(); using (var i = _packageCacheDic.GetEnumerator()) { RGPackage package = null; while (i.MoveNext()) { package = i.Current.Value; if (package != null) { if (package.IsLoadPackage) { if (!package.IsCacheNeedLoad) { if (!package.IsUI && package.IsAutoRelease && !package.IsForverBundle) { RGLog.DebugResLoad("<color=red> Auto Unload bundle</color> -> {0}", package.PackageName); package.UnloadAll();; unloadPackageList.Add(package.PackageName); } } } } } } for (int i = 0; i < unloadPackageList.Count; i++) { _packageCacheDic.Remove(unloadPackageList[i]); } }
public void UnloadAll() { if (_bundle != null) { RGLog.DebugResLoad("<color=red> unload all bundle </color> -> {0}", _packageName); _bundle.Unload(false); _bundle = null; } RGRes res = null; for (int i = 0; i < _cacheRes.Count; i++) { res = _cacheRes[i]; if (res != null) { RGLog.DebugResLoad("{0}:{1} \tRef:{2}", _packageName, res.ResName, res.RefCount); res.UnLoad(); } } _cacheRes.Clear(); // 清除list所占的内存 _cacheRes.TrimExcess(); Unloaded = true; }
IEnumerator LoadCache() { string assetName = ""; Action <UnityEngine.Object, LoadEventData> loadComplete = null; LoadEventData evData = null; for (int i = 0; i < _cacheAssetNameList.Count; i++) { assetName = _cacheAssetNameList[i]; loadComplete = _cacheCompleteList[i]; evData = _cacheEvDataList[i]; RGLog.DebugResLoad("Load Cache -> {0}", assetName); if (IsUI || IsForverBundle) { if (loadComplete != null) { loadComplete(_bundle, evData); } } else { LoadAssetAsync(assetName, loadComplete, evData); } yield return(0); } _cacheAssetNameList.Clear(); _cacheCompleteList.Clear(); _cacheEvDataList.Clear(); }
public bool UnloadRes(string assetName) { var res = FindRes(assetName); if (res == null) { RGLog.DebugResLoad("不用重复释放资源:{0}", assetName); return(false); } var refCount = res.DecRef(); { RGLog.DebugResLoad("<color=red>Unlod</color> {0}:{1} \tRef:{2}", _packageName, res.ResName, res.RefCount); if (refCount <= 0) { res.UnLoad(); RemoveRes(res); return(true); } } return(false); }
/// <summary> /// 创建文件夹 /// </summary> /// <param name="packageName"></param> /// <param name="filterName"></param> /// <param name="packagePaths"></param> private static void CreateAbData(string packageName, string filterName, params string[] packagePaths) { string[] pps = new string[packagePaths.Length]; for (int i = 0; i < packagePaths.Length; i++) { pps[i] = Path.Combine(RGResource.ROOT_PATH, packagePaths[i]); if (!Directory.Exists(pps[i])) { RGLog.DebugError("CreateAbData -> Path does not exist! " + pps[i]); } } string[] guids = AssetDatabase.FindAssets(filterName, pps); AssetBundleBuild abb = new AssetBundleBuild(); abb.assetBundleName = packageName; abb.assetNames = new string[guids.Length]; for (int i = 0; i < guids.Length; i++) { string filePath = AssetDatabase.GUIDToAssetPath(guids[i]); if (_abbGUIList.Contains(guids[i])) { RGLog.DebugError("Has Add AB Item:" + filePath); continue; } abb.assetNames[i] = filePath; } _abbList.Add(abb); }
public void LoadBundleAsync(string assetName, Action <UnityEngine.Object, LoadEventData> loadComplete, LoadEventData evData) { // 先检查包是否存在 if (!File.Exists(PackagePath)) { RGLog.Error("<color=red>LoadBundleAsync</color> PackagePath not exits!!! -> <color=yellow>{0}</color>", PackagePath); if (loadComplete != null) { loadComplete(null, evData); } return; } if (IsLoading) { AddCache(assetName, loadComplete, evData); RGLog.Debug("<color=green>Bundle Loading ! Add Cache {0} -> {1}</color>", _packageName, assetName); } else { AddCallback(assetName, loadComplete, evData); CoroutineManager.Instance.StartCoroutine(IELoadBundleAsync(assetName, loadComplete, evData)); } }
// 同步方式加载bundle private AssetBundle LoadBundle(string assetName) { // 先检查包是否存在 if (!File.Exists(PackagePath)) { RGLog.Error("<color=red>LoadBundle</color> PackagePath not exits!!!-><color=yellow>{0}</color>", PackagePath); return(null); } byte[] stream = null; AssetBundle bundle = null; stream = File.ReadAllBytes(PackagePath); if (stream != null) { bundle = AssetBundle.LoadFromMemory(stream); } else { RGLog.Error("Load Bundle From File Error :" + PackagePath); } _bundle = bundle; IsLoading = false; return(bundle); }
// 构建首包资源 public static void BuildFirstPackageResources() { var filesPath = Path.Combine(Application.streamingAssetsPath, "files.txt"); var fileData = File.ReadAllText(filesPath); var vFiles = ReadFileInfo(fileData); var versionPath = GetVersionBundlePath(); var outPathFix = Path.Combine(versionPath, "first"); if (Directory.Exists(outPathFix)) { Directory.Delete(outPathFix, true); } Directory.CreateDirectory(outPathFix); StringBuilder filesSb = new StringBuilder(); for (int i = 0; i < vFiles.Length; i++) { var vfData = vFiles[i]; var targetPath = Path.Combine(Application.streamingAssetsPath, vfData.Path).Replace("\\", "/"); var outPath = Path.Combine(outPathFix, vfData.Path).Replace("\\", "/"); foreach (BundleConfig bc in configData.ConfigList) { if (bc.NoInPackage && bc.BundleName.ToLower().Equals(vfData.Path.ToLower())) { if (File.Exists(targetPath)) { var path = Path.GetDirectoryName(outPath); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } filesSb.AppendLine(vfData.ToString()); File.Copy(targetPath, outPath); } break; } } } var outFilesPath = Path.Combine(outPathFix, "files.txt"); File.Copy(filesPath, outFilesPath); //写入首包文件列表 var outFirstFilesPath = Path.Combine(outPathFix, "first_files.txt"); File.WriteAllText(outFirstFilesPath, filesSb.ToString()); RGLog.Debug("构建首包资源完成"); }
public static void BuildFirstUPK() { // 版本路径 string versionPath = GetVersionBundlePath(); // 资源路径 string assetPath = Replace(string.Format("{0}{1}{2}", versionPath, Path.DirectorySeparatorChar, "first")); // 资源路径 string firstUpkPath = Replace(string.Format("{0}{1}{2}", versionPath, Path.DirectorySeparatorChar, "first_upk")); // upk 资源路径 string UPKPath = Replace(string.Format("{0}{1}{2}", assetPath, Path.DirectorySeparatorChar, "files.upk")); // UPK Info 资源路径 string streamingAssetPath = Replace(string.Format("{0}{1}{2}", Application.dataPath, Path.DirectorySeparatorChar, "StreamingAssets")); string InfoPath = Replace(string.Format("{0}{1}{2}", streamingAssetPath, Path.DirectorySeparatorChar, "first.txt")); // fristFile.txt 路径 string firstFilePath = Replace(string.Format("{0}{1}{2}", assetPath, Path.DirectorySeparatorChar, "first_files.txt")); // file.txt 路径 string filePath = Replace(string.Format("{0}{1}{2}", assetPath, Path.DirectorySeparatorChar, "files.txt")); // first upk dir if (Directory.Exists(firstUpkPath)) { Directory.Delete(firstUpkPath, true); } Directory.CreateDirectory(firstUpkPath); // 开始打包 List <UPKInfo> infoList = new List <UPKInfo>(); var fileData = File.ReadAllText(firstFilePath); var files = ReadFileInfo(fileData); for (int i = 0; i < files.Length; i++) { var file = files[i]; var fs = Replace(Path.Combine(assetPath, file.Path)); FileInfo filesInfo = new FileInfo(fs); UPKInfo filesuinfo = new UPKInfo(); filesuinfo.relativePath = "files.txt"; filesuinfo.absolutePath = filePath; filesuinfo.length = filesInfo.Length; infoList.Add(filesuinfo); } // 打包 UPKEngine.Pack(infoList, UPKPath, InfoPath); RGLog.Debug(" 生成 first upk 包"); }
public static RGPackage CreatePackage(string packageName) { RGLog.Debug(" CreatePackage --> " + packageName); var package = GetPackage(packageName); if (package == null) { package = RGPackage.Create(packageName); _packageCacheDic.Add(packageName, package); } return(package); }
// Texture2D public static void LoadTexture2DAsync(string path, Action <Texture2D, LoadEventData> loadComplete, params object[] data) { if (string.IsNullOrEmpty(path)) { RGLog.Error("<color=red> 加载 Texture2D Bundle 资源路径为空!!!</color>"); if (loadComplete != null) { loadComplete.Invoke(null, ParseFrom(data)); } return; } LoadAsync <Texture2D>(path, "png", loadComplete, ParseFrom(data)); }
//Gameobject public static void LoadGameObjectAsync(string path, Action <GameObject, LoadEventData> loadComplete, params object[] data) { if (string.IsNullOrEmpty(path)) { RGLog.Error("<color=red> 加载 GameObject Bundle 资源路径为空!!!</color>"); if (loadComplete != null) { loadComplete.Invoke(GameObject.CreatePrimitive(PrimitiveType.Cube), ParseFrom(data)); } return; } LoadAsync <GameObject>(path, "prefab", loadComplete, ParseFrom(data)); }
public static void LoadSoundEffectAsync(string path, Action <AudioClip, LoadEventData> loadComplete, params object[] data) { if (string.IsNullOrEmpty(path)) { RGLog.Error("<color=red> 加载 Sound Bundle 资源路径为空!!!</color>"); if (loadComplete != null) { loadComplete.Invoke(null, ParseFrom(data)); } return; } LoadAsync <AudioClip>(path, "ogg", loadComplete, ParseFrom(data)); }
// Scene public static void LoadSceneAsync(string path, Action <AssetBundle, LoadEventData> loadComplete, params object[] data) { if (string.IsNullOrEmpty(path)) { RGLog.Error("<color=red>加载 Scene 资源路径为空!!!</color>"); if (loadComplete != null) { loadComplete.Invoke(null, ParseFrom(data)); } return; } LoadAsync <AssetBundle>(path, "unity", loadComplete, ParseFrom(data)); }
private IEnumerator IELoadBundleAsync(string assetName, Action <UnityEngine.Object, LoadEventData> loadComplete, LoadEventData evData) { bool isLoadCache = false; if (!IsLoadPackage) { var bRequest = AssetBundle.LoadFromFileAsync(PackagePath); IsLoading = true; yield return(bRequest); var abRequest = bRequest.assetBundle; if (abRequest == null) { yield break; } if (!bRequest.isDone) { yield break; } _bundle = abRequest; IsLoading = false; // 加载缓存资源 isLoadCache = _cacheAssetNameList.Count > 0; } if (IsUI || IsForverBundle) { RGLog.DebugResLoad("<color=red>LoadUI</color> {0}", _packageName); if (loadComplete != null) { loadComplete(_bundle, evData); } } else { CoroutineManager.Instance.StartCoroutine(IELoadAssetAsync(assetName, loadComplete, evData)); yield return(0); } // 加载缓存 CoroutineManager.Instance.StartCoroutine(LoadCache()); yield return(null); }
public static void LoadUIAsync(string path, Action <AssetBundle, LoadEventData> loadComplete, params object[] data) { if (string.IsNullOrEmpty(path)) { RGLog.Error("资源为空 ---------->" + path); if (loadComplete != null) { loadComplete.Invoke(null, ParseFrom(data)); } return; } LoadAsync <AssetBundle>(path, "", loadComplete, ParseFrom(data)); }
private void DownloadHot() { state = STATE.DOWNLLOAD_HOT; hotUI.HOT_InitHot(); //内存判断 if (PGameTools.GetStorageSize() < updateSize) { hotUI.OutOfMemory(updateSize); return; } currentUpdateVersionFileIndex = updateVersionFileCount - updateVersionFileList.Count + 1; var fileInfo = updateVersionFileList[0]; var url = FormatUrl(serverUrl, GetRouteRoot() + fileInfo.WebPath); var localPath = fileInfo.DataLocalPath; if (download == null) { download = HotDownload.Create(); } download.Download(url, localPath, () => { RGLog.Log("热更新下载 url : " + url); }, () => { updateVersionFileList.RemoveAt(0); if (updateVersionFileList.Count > 0) { DownloadHot(); } else { hotUI.HOT_HotFinished(); EnterGame(); } }, (progress) => { hotUI.HOT_SetHotProgress(updateVersionFileCount, currentUpdateVersionFileIndex, progress); }, (error) => { hotUI.HOT_HotError(error, this); }); }
/// <summary> /// 打包UPK /// </summary> /// <param name="infoList"></param> /// <param name="upkPath"></param> /// <param name="infoPath"></param> public static void Pack(List <UPKInfo> infoList, string upkPath, string infoPath) { //检查upk目录 var dirUpk = Path.GetDirectoryName(upkPath); if (!Directory.Exists(dirUpk)) { Directory.CreateDirectory(dirUpk); } if (File.Exists(upkPath)) { File.Delete(upkPath); } //检查 info 目录 string dirInfo = Path.GetDirectoryName(infoPath); if (!Directory.Exists(dirInfo)) { Directory.CreateDirectory(dirInfo); } if (File.Exists(infoPath)) { File.Delete(infoPath); } // 打包UPK FileStream upkStream = new FileStream(upkPath, FileMode.Create); for (int i = 0; i < infoList.Count; i++) { var info = infoList[i]; FileStream fileStreamRead = new FileStream(info.absolutePath, FileMode.Open, FileAccess.Read); if (fileStreamRead == null) { RGLog.Log("读取文件失败:" + info.relativePath); return; } byte[] fileData = new byte[info.length]; fileStreamRead.Read(fileData, 0, (int)info.length); fileStreamRead.Close(); upkStream.Write(fileData, 0, (int)info.length); } }
/// <summary> /// 拷贝first upk 到 bundle 目录 /// </summary> public static void CopyFirstUpkToBundle() { // 版本路径 string versiongPath = GetVersionBundlePath(); // UPK 资源路径 string firstUpkPath = Replace(string.Format("{0}{1}{2}{3}{4}", versiongPath, Path.DirectorySeparatorChar, "first_upk", Path.DirectorySeparatorChar, "first.upk")); // 目标路径 string targetPath = Replace(string.Format("{0}{1}{2}{3}{4}{5}{6}", versiongPath, Path.DirectorySeparatorChar, "bundle", Path.DirectorySeparatorChar, VersionInfo.BundleVersion, Path.DirectorySeparatorChar, "first.upk")); if (File.Exists(firstUpkPath)) { File.Copy(firstUpkPath, targetPath); } RGLog.Debug(" first upk copy to bundle finished !"); }
// 下载首包 private void DownloadFirstUpk() { state = STATE.DOWNLOAD_FIRST_ZIP; hotUI.HOT_InitDownloadFirst(); // 内存判断 if (PGameTools.GetStorageSize() < DownloadFirstMemorySize) { hotUI.OutOfMemory(DownloadFirstMemorySize); return; } var url = string.Format("{0}{1}/{2}/{3}", serverUrl, GetRouteRoot().TrimStart('/'), VersionInfo.BundleVersion, "first.upk"); var localPath = Path.Combine(Util.DataPath, "first.upk"); // 需要下载首包 if (download == null) { download = HotDownload.Create(); } download.Download(url, localPath, () => { RGLog.Log("首包开始下载"); }, () => { hotConfig.first_upk_download = HOT_STATE.SUCCEED; hotConfig.Save(); hotUI.HOT_DownloadFirstFinished(); //解首包 upk UnpackFirstUpk(); }, (progress) => { hotUI.HOT_SetDownloadFirstProgress(progress); }, (error) => { hotUI.HOT_DownloadFirstError(error, this); }); }
// 保存开发模式下开发人员配置 public void SaveDevelop() { RGLog.Log("保存 Develop Hot Config 配置 :" + configPath); if (File.Exists(configPath)) { File.Delete(configPath); } StringBuilder hotSb = new StringBuilder(); hotSb.AppendLine("{"); hotSb.AppendFormat("\t\"{0}\":{1},\n", "first_upk_download", HOT_STATE.SUCCEED); hotSb.AppendFormat("\t\"{0}\":{1},\n", "first_upk_unpack", HOT_STATE.SUCCEED); hotSb.AppendFormat("\t\"{0}\":{1},\n", "streaming_upk_unpack", HOT_STATE.SUCCEED); hotSb.AppendLine("}"); File.WriteAllText(configPath, hotSb.ToString()); }
public void Move(int newX, int newY, float time) { Vector2 oldPos = ChangePostion(X, Y); Vector2 newPos = ChangePostion(newX, newY); X = newX; Y = newY; DOTween.To(() => oldPos, pos => { try { _sweet.xy = pos; } catch (Exception e) { RGLog.Warn(e); } }, newPos, time); }
private static void EndAsset() { if (!Directory.Exists(_exportPath)) { Directory.CreateDirectory(_exportPath); } AssetBundleManifest abm = BuildPipeline.BuildAssetBundles(_exportPath, _abbList.ToArray(), BuildAssetBundleOptions.ChunkBasedCompression | BuildAssetBundleOptions.StrictMode | BuildAssetBundleOptions.DeterministicAssetBundle, buildTarget); if (abm != null) { string[] abs = abm.GetAllAssetBundles(); for (int i = 0; i < abs.Length; i++) { RGLog.Debug("AB: " + abs[i]); } } }
public static void BuildDeveloper() { var filesPath = Path.Combine(Application.streamingAssetsPath, "files.txt"); var fileData = File.ReadAllText(filesPath); var vFiles = ReadFileInfo(fileData); var outPathFix = Util.DataPath; RGLog.Debug("outPath ->" + outPathFix); if (Directory.Exists(outPathFix)) { Directory.Delete(outPathFix, true); } // copy for (int i = 0; i < vFiles.Length; i++) { var vfData = vFiles[i]; var targetPath = Path.Combine(Application.streamingAssetsPath, vfData.Path).Replace("\\", "/"); var outPath = Path.Combine(outPathFix, vfData.Path).Replace("\\", "/"); var path = Path.GetDirectoryName(outPath); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } RGLog.Debug("outPath 2 ->" + outPathFix); File.Copy(targetPath, outPath); } var outFilesPath = Path.Combine(outPathFix, "files.txt").Replace("\\", "/"); File.Copy(filesPath, outFilesPath); RGLog.Debug("构建开发使用资源"); }
// 获得AssetBundle资源包名 public static string GetPackageName(string path) { string[] model = path.ToLower().Split(RGResource.PATH_SEPARATOR); // 包路径 string packageUrl = ""; for (int i = 0; i < model.Length; i++) { RGLog.Debug(model[i]); } if (model.Length > 0) { if (model[0].Equals("ui")) { // ui packageUrl = "ui/" + model[1]; } return(packageUrl.ToLower()); } RGLog.DebugError(" GetPackagePath Error! Path is Empty"); return(string.Empty); }
// 从 cnd 上获取 配置信息 IEnumerator GetConfig(string tandbyAddress = "") { string configUrl = ""; if (VersionInfo.BType == VersionInfo.BUILD_TYPE.DEVELOP || VersionInfo.BType == VersionInfo.BUILD_TYPE.DEVELOP_SPECITFY_SERVER || VersionInfo.BType == VersionInfo.BUILD_TYPE.DEVELOP_SELECT_SERVER) { configUrl = "http://192.168.1.253./platform/devConfig.json"; } else if (VersionInfo.BType == VersionInfo.BUILD_TYPE.LIVE || VersionInfo.BType == VersionInfo.BUILD_TYPE.LIVE_LOG) { if (string.IsNullOrEmpty(tandbyAddress)) { configUrl = "http://www.baidu.com"; } else { configUrl = tandbyAddress; } } Debug.Log("Config Url" + configUrl); WWW www = new WWW(configUrl); yield return(www); if (www.error != null) { RGLog.Warn("[GameManager] > GetConfig 02"); RGLog.Error(www.error); // 错误提示弹窗 hotUI.ShowPopup("错误", "提示", () => { Timers.inst.StartCoroutine(GetConfig("http://www.baidu.com/备用")); }, () => { Application.Quit(); }, "Retry", "Quit"); } else { if (www.isDone) { ConfigJson config = JsonUtility.FromJson <ConfigJson>(www.text); AppConst.WebUrl = config.UpdateUrl; if (VersionInfo.BType == VersionInfo.BUILD_TYPE.LIVE_LOG) { //资源更新地址 AppConst.WebUrl = "http://192.168.1.253/platform/"; //备用资源更新地址 AppConst.UpdateUrl2 = "http://192.168.1.253/platform"; } //校验版本 Timers.inst.StartCoroutine(CheckVersionInfo()); } } }
private void OnGUI() { EditorGUILayout.BeginVertical(); fontStyle.fontSize = 15; fontStyle.normal.textColor = Color.white; GUILayout.Label("正式资源操作", fontStyle); // ******************** 此处开始为热更操作 ********************* GUILayout.Space(20); fontStyle.fontSize = 15; fontStyle.normal.textColor = Color.white; GUILayout.Label("热更资源操作", fontStyle); GUILayout.Space(10); GUILayout.BeginHorizontal(); if (GUILayout.Button("清理资源备选名单")) { RGLog.Debug(" 清理资源备选名单 "); GenerateHotAlternativeScriptable(); ClearHotAlternativeScriptable(); } if (GUILayout.Button("生成资源备选名单")) { RGLog.Debug(" 生成资源备选名单 "); GenerateHotObject(); } GUILayout.EndHorizontal(); if (hotObject != null) { if (hotObject.DataList.Count > 0) { if (GUILayout.Button("build hot bundle")) { BuildABTools.BuildHotAll(hotObject.DataList); } GUILayout.Space(10); GUILayout.Label("热更资源名单[" + hotObject.DataList.Count + "]"); EditorGUILayout.BeginScrollView(Vector2.zero, GUILayout.Height(hotObject.DataList.Count * 20)); for (int i = 0; i < hotObject.DataList.Count; i++) { if (hotObject.DataList[i].selected) { EditorGUILayout.LabelField(hotObject.DataList[i].package); } } EditorGUILayout.EndScrollView(); } else { GUILayout.Space(10); fontStyle.fontSize = 12; fontStyle.normal.textColor = Color.red; GUILayout.Label("备注:\n1.请在资源备选名单中选择要热更的资源\n2.然后再执行'生成热更资源名单' ", fontStyle); } } else { GenerateHotObject(); } EditorGUILayout.EndVertical(); }
public static void BuileFileIndex() { string buildVersion = "0.0.1"; List <string> _files = new List <string>(); string resPath = _exportPath; if (!Directory.Exists(resPath)) { Directory.CreateDirectory(resPath); } string newFilePath = string.Format("{0}{1}", resPath, "/files.txt"); if (File.Exists(newFilePath)) { File.Delete(newFilePath); } string[] allFiles = Directory.GetFiles(resPath, "*.*", SearchOption.AllDirectories); _files.AddRange(allFiles); var fs = new FileStream(newFilePath, FileMode.CreateNew); var sw = new StreamWriter(fs); for (int i = 0; i < _files.Count; i++) { string file = _files[i]; if (file.EndsWith(".DS_Store")) { continue; } if (file.EndsWith("StreamingAssets")) { continue; } string ext = Path.GetExtension(file); if (ext.EndsWith(".meta")) { continue; } if (ext.EndsWith(".txt")) { continue; } if (ext.EndsWith(".manifest")) { continue; } if (ext.EndsWith(".mp4")) { continue; } if (ext.EndsWith(".zip")) { continue; } var verfile = new VersionFile(); verfile.Path = file.Replace(resPath + Path.DirectorySeparatorChar, string.Empty) .Replace(Path.DirectorySeparatorChar, '/'); verfile.Hash = Util.md5file(file); verfile.Version = buildVersion; FileInfo fileInfo = new FileInfo(file); verfile.Size = fileInfo.Length; sw.WriteLine(verfile); } sw.Close(); fs.Close(); sw.Dispose(); fs.Dispose(); RGLog.Debug(" Build File Index "); }