From 1cee93d63f19fd4e961b47f23cfa7621833e7d7f Mon Sep 17 00:00:00 2001 From: client_Wu Xijin <364452445@qq.com> Date: 星期一, 05 十一月 2018 13:49:26 +0800 Subject: [PATCH] Merge branch 'master' into leonard --- Assets/Editor/Tool/ClientPackage.cs | 108 ++++++++++++++++++++++++++++++++++++++++++----------- 1 files changed, 85 insertions(+), 23 deletions(-) diff --git a/Assets/Editor/Tool/ClientPackage.cs b/Assets/Editor/Tool/ClientPackage.cs index 520d04b..3c1b59a 100644 --- a/Assets/Editor/Tool/ClientPackage.cs +++ b/Assets/Editor/Tool/ClientPackage.cs @@ -22,8 +22,13 @@ } public static bool obfuscatorEnabled { - get { return LocalSave.GetBool("obfuscatorEnabled",false); } + get { return LocalSave.GetBool("obfuscatorEnabled", false); } set { LocalSave.SetBool("obfuscatorEnabled", value); } + } + + public static int AssetPrior { + get { return LocalSave.GetInt("HalfAssetPrior", 1); } + set { LocalSave.SetInt("HalfAssetPrior", value); } } static string ANDROID_PLUGIN_PATH = Application.dataPath + "/Plugins/Android"; @@ -130,11 +135,14 @@ if (halfPackages.Count > 0) { Config.Instance.LoadPriorBundleConfig(); - FileExtersion.DirectoryCopy(_assetBundlePath, ResourcesPath.Instance.StreamingAssetPath); - var files = new List<FileInfo>(); - FileExtersion.GetAllDirectoryFileInfos(StringUtility.Contact(ResourcesPath.Instance.StreamingAssetPath, "mob"), files); - foreach (var file in files) + var fromFiles = new List<FileInfo>(); + FileExtersion.GetAllDirectoryFileInfos(_assetBundlePath, fromFiles); + + var excludeFileFullNames = new List<string>(); + var tempFiles = new List<FileInfo>(); + FileExtersion.GetAllDirectoryFileInfos(StringUtility.Contact(_assetBundlePath, "/mob"), tempFiles); + foreach (var file in tempFiles) { var extersion = Path.GetExtension(file.FullName); var fileName = Path.GetFileName(file.FullName); @@ -143,15 +151,16 @@ fileName = fileName.Replace(extersion, ""); } - if (!PriorBundleConfig.mobs.Contains(fileName)) + var prior = PriorBundleConfig.GetAssetPrior(AssetVersion.AssetCategory.Mob, fileName); + if (prior > AssetPrior) { - File.Delete(file.FullName); + excludeFileFullNames.Add(file.FullName); } } - files.Clear(); - FileExtersion.GetAllDirectoryFileInfos(StringUtility.Contact(ResourcesPath.Instance.StreamingAssetPath, "maps"), files); - foreach (var file in files) + tempFiles.Clear(); + FileExtersion.GetAllDirectoryFileInfos(StringUtility.Contact(_assetBundlePath, "/maps"), tempFiles); + foreach (var file in tempFiles) { var extersion = Path.GetExtension(file.FullName); var fileName = Path.GetFileName(file.FullName); @@ -160,15 +169,16 @@ fileName = fileName.Replace(extersion, ""); } - if (!PriorBundleConfig.scenes.Contains(fileName)) + var prior = PriorBundleConfig.GetAssetPrior(AssetVersion.AssetCategory.Scene, fileName); + if (prior > AssetPrior) { - File.Delete(file.FullName); + excludeFileFullNames.Add(file.FullName); } } - files.Clear(); - FileExtersion.GetAllDirectoryFileInfos(StringUtility.Contact(ResourcesPath.Instance.StreamingAssetPath, "audio"), files); - foreach (var file in files) + tempFiles.Clear(); + FileExtersion.GetAllDirectoryFileInfos(StringUtility.Contact(_assetBundlePath, "/audio"), tempFiles); + foreach (var file in tempFiles) { var extersion = Path.GetExtension(file.FullName); var fileName = Path.GetFileName(file.FullName); @@ -177,15 +187,16 @@ fileName = fileName.Replace(extersion, ""); } - if (!PriorBundleConfig.audios.Contains(fileName)) + var prior = PriorBundleConfig.GetAssetPrior(AssetVersion.AssetCategory.Audio, fileName); + if (prior > AssetPrior) { - File.Delete(file.FullName); + excludeFileFullNames.Add(file.FullName); } } - files.Clear(); - FileExtersion.GetAllDirectoryFileInfos(StringUtility.Contact(ResourcesPath.Instance.StreamingAssetPath, "effect"), files); - foreach (var file in files) + tempFiles.Clear(); + FileExtersion.GetAllDirectoryFileInfos(StringUtility.Contact(_assetBundlePath, "/effect"), tempFiles); + foreach (var file in tempFiles) { var extersion = Path.GetExtension(file.FullName); var fileName = Path.GetFileName(file.FullName); @@ -194,12 +205,63 @@ fileName = fileName.Replace(extersion, ""); } - if (!PriorBundleConfig.effects.Contains(fileName)) + var prior = PriorBundleConfig.GetAssetPrior(AssetVersion.AssetCategory.Effect, fileName); + if (prior > AssetPrior) { - File.Delete(file.FullName); + excludeFileFullNames.Add(file.FullName); } } + tempFiles.Clear(); + FileExtersion.GetAllDirectoryFileInfos(StringUtility.Contact(_assetBundlePath, "/ui/sprite"), tempFiles); + foreach (var file in tempFiles) + { + var fileName = Path.GetFileName(file.FullName); + if (fileName == "loadingbg") + { + excludeFileFullNames.Add(file.FullName); + } + } + + for (int i = fromFiles.Count - 1; i >= 0; i--) + { + var item = fromFiles[i]; + if (excludeFileFullNames.Contains(item.FullName)) + { + fromFiles.RemoveAt(i); + } + } + + var totalCount = fromFiles.Count; + var completeCount = 0; + foreach (var item in fromFiles) + { + var directory = Path.GetDirectoryName(item.FullName); + if (!Directory.Exists(directory)) + { + Directory.CreateDirectory(directory); + } + + var relativePath = FileExtersion.GetFileRelativePath(_assetBundlePath, item.FullName); + var to = StringUtility.Contact(ResourcesPath.Instance.StreamingAssetPath, relativePath); +#if UNITY_ANDROID + var extension = Path.GetExtension(item.FullName); + if (extension == ".meta") + { + continue; + } + + to = to + ".7z"; + SevenZipUtility.Compress(item.FullName, to); + UnityEditor.EditorUtility.DisplayProgressBar("姝e湪鍘嬬缉璧勬簮", item.Name, (float)completeCount / totalCount); +#elif UNITY_IOS + File.Copy(item.FullName,to,true); +#endif + + completeCount++; + } + + EditorUtility.ClearProgressBar(); for (int i = 0; i < halfPackages.Count; i++) { #if UNITY_ANDROID @@ -292,7 +354,7 @@ FileExtersion.DirectoryCopy(StringUtility.Contact(_sdkPath, "/ChannelDiff/Android/", versionConfig.appId), ANDROID_PLUGIN_PATH); var option = AssetDatabase.LoadAssetAtPath<Options>("Assets/Editor/Beebyte/Obfuscator/ObfuscatorOptions.asset"); - if (option!=null) + if (option != null) { option.enabled = obfuscatorEnabled; EditorUtility.SetDirty(option); -- Gitblit v1.8.0