private static void CleanIndexFiles() { if (Directory.Exists(AssetBundleHelper.GetOuterStreamingAssetsPath() + "/IndexFiles")) { Directory.Delete(AssetBundleHelper.GetOuterStreamingAssetsPath() + "/IndexFiles", true); } }
static void SwitchAssetDelteData() { string[] files = Directory.GetFiles(AssetBundleHelper.GetOuterStreamingAssetsPath(), "*.*", SearchOption.AllDirectories); foreach (var file in files) { string filePath = file.Replace("\\", "/"); if (filePath.Contains("StreamingAssets/AssetBundles")) { continue; } File.Delete(filePath); } files = Directory.GetDirectories(AssetBundleHelper.GetOuterStreamingAssetsPath(), "*.*", SearchOption.AllDirectories); foreach (var file in files) { string filePath = file.Replace("\\", "/"); if (filePath.Contains("StreamingAssets/AssetBundles") || Directory.Exists(filePath) == false) { continue; } Directory.Delete(filePath, true); } Debug.Log("<color='#00ff00'>删除StreamingAssets Other资源完成</color>"); }
public static void DeleteOuterStreamingAssets_AssetBundles() { if (Directory.Exists(AssetBundleHelper.GetOuterStreamingAssetsPath() + "/AssetBundles") == false) { return; } Directory.Delete(AssetBundleHelper.GetOuterStreamingAssetsPath() + "/AssetBundles", true); Debug.Log("<color='#00ff00'>删除StreamingAssets AssetBundles资源完成</color>"); }
static void CopyAllResToStreamingAssets() { DeleteOuterStreamingAssets_AssetBundles(); string originalBundlePath = AssetBundleHelper.GetOriginalBundlesPath().Replace("\\", "/") + "/"; string streamingAssetsPath = AssetBundleHelper.GetOuterStreamingAssetsPath() + "/"; string[] files = Directory.GetFiles(PackageManager.GetAssetBundleDir(), "*", SearchOption.AllDirectories); int count = 0; int len = files.Length / 2; for (int i = 0; i < files.Length; i++) { string filePath = files[i]; if (filePath.EndsWith(".manifest")) { continue; } string relatePath = filePath.Replace("\\", "/").Replace(originalBundlePath, ""); string destFile = string.Empty; FileInfo fileInfo = null; destFile = streamingAssetsPath + relatePath; fileInfo = new FileInfo(destFile); if (fileInfo.Directory.Exists == false) { fileInfo.Directory.Create(); } count++; EditorUtility.DisplayProgressBar("复制文件", "(" + count + "/" + len + ")", (float)count / len); File.Copy(filePath, destFile, true); } EditorUtility.ClearProgressBar(); Debug.Log("<color='#00ff00'>复制所有Bundle到StreamingAssets完成</color> 文件数量:" + count); FiltrateCoaxSleepAudio(); }
/// <summary> /// 以简体中文配置为主,其他多语言文件夹放置有区别的文本就行了 /// </summary> private static void CopyI18nDataZH_CN() { string path = Application.dataPath.Replace("Assets", "I18NData").Replace("\\", "/") + "/zh-cn"; string streamingAssetsPath = AssetBundleHelper.GetOuterStreamingAssetsPath() + "/"; string[] files = Directory.GetFiles(path, "*.*", SearchOption.AllDirectories); foreach (var file in files) { string filePath = file.Replace("\\", "/"); string destFile = filePath.Replace(path, ""); destFile = streamingAssetsPath + destFile; CreateDir(destFile); File.Copy(file, destFile, true); } }
public static void SignatureLua() { Process process = new Process(); string path = Application.dataPath.Replace("Assets", "Tools"); process.StartInfo.FileName = path + "/FilesSignature.exe"; process.StartInfo.WorkingDirectory = path; process.StartInfo.Arguments = PackageManager.I18NDataPath + "/LuaFiles " + AssetBundleHelper.GetOuterStreamingAssetsPath() + "/LuaFiles"; process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; process.StartInfo.RedirectStandardOutput = true; process.StartInfo.UseShellExecute = false; process.StartInfo.CreateNoWindow = true; process.Start(); UnityEngine.Debug.Log(process.StandardOutput.ReadToEnd()); process.WaitForExit(); }
static void DownloadFirstRunBunlde() { Stopwatch sw = Stopwatch.StartNew(); CleanIndexFiles(); PublishRes.DeleteOuterStreamingAssets_AssetBundles(); Debug.LogWarning("删除文件时间:" + sw.ElapsedMilliseconds / 1000.0f + "ms"); sw.Restart(); FileUtil.CopyFolder(GetPackagePcRoot + "/" + Folder + "/StreamingAssets/AssetBundles", AssetBundleHelper.GetOuterStreamingAssetsPath() + "/AssetBundles"); Debug.LogWarning("复制OuterStreamingAssetsPath文件时间:" + sw.ElapsedMilliseconds / 1000.0f + "ms"); sw.Restart(); FileUtil.CopyFolder(GetPackagePcRoot + "/" + Folder + "/StreamingAssets/IndexFiles", AssetBundleHelper.GetOuterStreamingAssetsPath() + "/IndexFiles"); Debug.LogWarning("复制IndexFiles文件时间:" + sw.ElapsedMilliseconds / 1000.0f + "ms"); }
static void CopyIndexFileToStreamingAsset() { string dir = PackageManager.OutputPath; string[] files = Directory.GetFiles(dir); if (files.Length == 0) { EditorUtility.DisplayDialog("警告", "索引文件不存在(" + dir + ")", "OK"); return; } string destDir = AssetBundleHelper.GetOuterStreamingAssetsPath() + "/IndexFiles/"; CreateDir(destDir); foreach (var file in files) { string fileName = Path.GetFileName(file); File.Copy(file, destDir + fileName, true); } }
static void CopyI18nData(bool showConfirm) { if (showConfirm && EditorUtility.DisplayDialog("切换资源", "是否切换资源到" + PackageManager.Language + "语言", "确定切换", "取消") == false) { return; } I18NManager.LanguageType languageType = (I18NManager.LanguageType)EditorPrefs.GetInt(PublishRes.ResPublish_LanguageKey); if (languageType != I18NManager.LanguageType.ChineseSimplified) { CopyI18nDataZH_CN(); } string path = PackageManager.I18NDataPath.Replace("\\", "/") + "/"; string streamingAssetsPath = AssetBundleHelper.GetOuterStreamingAssetsPath() + "/"; if (Directory.Exists(path) == false) { return; } string[] files = Directory.GetFiles(path, "*.*", SearchOption.AllDirectories); foreach (var file in files) { string filePath = file.Replace("\\", "/"); string destFile = filePath.Replace(path, ""); destFile = streamingAssetsPath + destFile; CreateDir(destFile); File.Copy(file, destFile, true); } Debug.Log("<color='#00ff00'>切换文本到" + PackageManager.Language + "语言完成</color> 文件数量:" + files.Length); }
static void SwitchAssetDelteAll() { Directory.Delete(AssetBundleHelper.GetOuterStreamingAssetsPath(), true); Debug.Log("<color='#00ff00'>删除所有OuterStreamingAssets资源完成</color>"); }
static void CopyResToStreamingAssets() { DeleteOuterStreamingAssets_AssetBundles(); Dictionary <string, bool> fileDict = new Dictionary <string, bool>(); LoadIndexJson(ResPath.MainStoryIndex, ref fileDict); LoadIndexJson(ResPath.LoveStoryIndex, ref fileDict); LoadIndexJson(ResPath.EvoCardIndex, ref fileDict); LoadIndexJson(ResPath.LoveVisitIndex, ref fileDict); LoadIndexJson(ResPath.PhoneAudioPackageIndex, ref fileDict); LoadIndexJson(ResPath.AppStart, ref fileDict); LoadIndexJson(ResPath.Extend, ref fileDict); LoadIndexJson(ResPath.Backend, ref fileDict); LoadIndexJson(ResPath.Special, ref fileDict); LoadIndexJson(ResPath.IncludeIndex, ref fileDict, true); string originalBundlePath = AssetBundleHelper.GetOriginalBundlesPath().Replace("\\", "/") + "/"; string streamingAssetsPath = AssetBundleHelper.GetOuterStreamingAssetsPath() + "/"; string[] files = Directory.GetFiles(PackageManager.GetAssetBundleDir(), "*", SearchOption.AllDirectories); // int len = files.Length / 2 - fileDict.Count; string destDir = PackageManager.GetPackageDir() + "/" + ResPath.AllResources; if (Directory.Exists(destDir)) { Directory.Delete(destDir, true); } int len = files.Length / 2; int count = 0; int inPackageCount = 0; for (int i = 0; i < files.Length; i++) { string filePath = files[i]; if (filePath.EndsWith(".manifest")) { continue; } string relatePath = filePath.Replace("\\", "/").Replace(originalBundlePath, ""); if (fileDict.ContainsKey(relatePath)) { string path = PackageManager.GetPackageDir() + "/" + ResPath.AllResources + "/" + relatePath; destDir = Path.GetDirectoryName(path); if (Directory.Exists(destDir) == false) { Directory.CreateDirectory(destDir); } File.Copy(filePath, path); } else { string destFile = streamingAssetsPath + relatePath; FileInfo fileInfo = new FileInfo(destFile); if (fileInfo.Directory.Exists == false) { fileInfo.Directory.Create(); } File.Copy(filePath, destFile); inPackageCount++; } count++; EditorUtility.DisplayProgressBar("复制文件", "(" + count + "/" + len + ")" + " 包内:" + inPackageCount, (float)count / len); } CreateAllDownloadJsonAndZip(); EditorUtility.ClearProgressBar(); CopyIndexFileToStreamingAsset(); Debug.Log("<color='#00ff00'>复制优化后的Bundle到StreamingAssets完成</color> 文件数量:" + count); }