From 4374fa1e1ca92b1a19134b6079e8d68b4bd7eca8 Mon Sep 17 00:00:00 2001 From: CatImmortal <1304085906@qq.com> Date: Wed, 15 Mar 2023 10:00:59 +0800 Subject: [PATCH] =?UTF-8?q?[refactor][editor]:=E9=87=8D=E6=9E=84ConfigWind?= =?UTF-8?q?ow=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Editor/Config/BundleBuildDirectory.cs | 24 +++- .../SubWindows/Config/ConfigWindow.cs | 114 +++++++++++++----- 2 files changed, 103 insertions(+), 35 deletions(-) diff --git a/Assets/CatAsset/Editor/Config/BundleBuildDirectory.cs b/Assets/CatAsset/Editor/Config/BundleBuildDirectory.cs index a26b5ef6..99ee0996 100644 --- a/Assets/CatAsset/Editor/Config/BundleBuildDirectory.cs +++ b/Assets/CatAsset/Editor/Config/BundleBuildDirectory.cs @@ -13,6 +13,12 @@ namespace CatAsset.Editor [Serializable] public class BundleBuildDirectory : IComparable { + /// + /// 目录名 + /// + [SerializeField] + private string directoryName; + /// /// 目录对象 /// @@ -48,12 +54,23 @@ public class BundleBuildDirectory : IComparable /// 资源包加密设置 /// [SerializeField] - public BundleEncryptOptions EncryptOption; - + public BundleEncryptOptions EncryptOption; + /// /// 目录名 /// - public string DirectoryName => AssetDatabase.GetAssetPath(DirectoryObj); + public string DirectoryName + { + get + { + if (DirectoryObj != null) + { + directoryName = AssetDatabase.GetAssetPath(DirectoryObj); + } + + return directoryName; + } + } public BundleBuildDirectory(string directoryName, string buildRuleName = nameof(NAssetToOneBundle), string regex = null, string group = GroupInfo.DefaultGroup, @@ -61,6 +78,7 @@ public BundleBuildDirectory(string directoryName, string buildRuleName = nameof( BundleEncryptOptions encryptOption = BundleEncryptOptions.UseGlobal ) { + this.directoryName = directoryName; DirectoryObj = AssetDatabase.LoadAssetAtPath(directoryName); BuildRuleName = buildRuleName; Regex = regex; diff --git a/Assets/CatAsset/Editor/Window/BundleBuildWindow/SubWindows/Config/ConfigWindow.cs b/Assets/CatAsset/Editor/Window/BundleBuildWindow/SubWindows/Config/ConfigWindow.cs index 15e89007..6794231b 100644 --- a/Assets/CatAsset/Editor/Window/BundleBuildWindow/SubWindows/Config/ConfigWindow.cs +++ b/Assets/CatAsset/Editor/Window/BundleBuildWindow/SubWindows/Config/ConfigWindow.cs @@ -37,6 +37,30 @@ public override void DrawSubWindow(Rect position) { EditorGUI.BeginChangeCheck(); + DrawVersion(); + + DrawTargetPlatforms(); + + DrawOptions(); + + DrawOnlyBuildRaw(); + + DrawCopyGroup(); + + DrawButtons(); + + if (EditorGUI.EndChangeCheck()) + { + EditorUtility.SetDirty(BundleBuildConfigSO.Instance); + AssetDatabase.SaveAssets(); + } + } + + /// + /// 绘制版本号 + /// + private static void DrawVersion() + { using (new EditorGUILayout.HorizontalScope()) { EditorGUILayout.LabelField("安装包版本号:" + Application.version, GUILayout.Width(200)); @@ -46,7 +70,14 @@ public override void DrawSubWindow(Rect position) EditorGUILayout.IntField(BundleBuildConfigSO.Instance.ManifestVersion, GUILayout.Width(50)); } - EditorGUILayout.Space(); + EditorGUILayout.Separator(); + } + + /// + /// 绘制构建平台 + /// + private void DrawTargetPlatforms() + { EditorGUILayout.LabelField("选择资源包构建平台:"); using (new EditorGUILayout.HorizontalScope()) { @@ -73,18 +104,24 @@ public override void DrawSubWindow(Rect position) } } - EditorGUILayout.Space(); + EditorGUILayout.Separator(); + } + /// + /// 绘制选项 + /// + private static void DrawOptions() + { using (new EditorGUILayout.HorizontalScope()) { - EditorGUILayout.LabelField("资源包构建设置:",GUILayout.Width(100)); + EditorGUILayout.LabelField("资源包构建设置:", GUILayout.Width(100)); BundleBuildConfigSO.Instance.Options = (BundleBuildOptions)EditorGUILayout.EnumFlagsField(BundleBuildConfigSO.Instance.Options, GUILayout.Width(200)); - - EditorGUILayout.Space(); - - EditorGUILayout.LabelField("资源包全局压缩设置:",GUILayout.Width(120)); + + EditorGUILayout.Separator(); + + EditorGUILayout.LabelField("资源包全局压缩设置:", GUILayout.Width(120)); BundleCompressOptions compressOptions = (BundleCompressOptions)EditorGUILayout.EnumPopup(BundleBuildConfigSO.Instance.GlobalCompress, GUILayout.Width(100)); @@ -92,10 +129,10 @@ public override void DrawSubWindow(Rect position) { BundleBuildConfigSO.Instance.GlobalCompress = compressOptions; } - - EditorGUILayout.Space(); - - EditorGUILayout.LabelField("资源包全局加密设置:",GUILayout.Width(120)); + + EditorGUILayout.Separator(); + + EditorGUILayout.LabelField("资源包全局加密设置:", GUILayout.Width(120)); BundleEncryptOptions encryptOption = (BundleEncryptOptions)EditorGUILayout.EnumPopup(BundleBuildConfigSO.Instance.GlobalEncrypt, GUILayout.Width(100)); @@ -103,11 +140,12 @@ public override void DrawSubWindow(Rect position) { BundleBuildConfigSO.Instance.GlobalEncrypt = encryptOption; } - - EditorGUILayout.Space(); - + + EditorGUILayout.Separator(); + GUILayout.Label("资源包构建输出根目录:", GUILayout.Width(150)); - BundleBuildConfigSO.Instance.OutputPath = GUILayout.TextField(BundleBuildConfigSO.Instance.OutputPath,GUILayout.Width(300)); + BundleBuildConfigSO.Instance.OutputPath = + GUILayout.TextField(BundleBuildConfigSO.Instance.OutputPath, GUILayout.Width(300)); if (GUILayout.Button("选择目录", GUILayout.Width(100))) { string folder = EditorUtility.OpenFolderPanel("选择资源包构建输出根目录", BundleBuildConfigSO.Instance.OutputPath, ""); @@ -117,20 +155,31 @@ public override void DrawSubWindow(Rect position) } } } - EditorGUILayout.Space(); - + EditorGUILayout.Separator(); + } - EditorGUILayout.Space(); + /// + /// 绘制仅构建原生资源包 + /// + private void DrawOnlyBuildRaw() + { + EditorGUILayout.Separator(); using (EditorGUILayout.ToggleGroupScope toggle = new EditorGUILayout.ToggleGroupScope("仅构建原生资源包", isOnlyBuildRaw)) { isOnlyBuildRaw = toggle.enabled; } - - EditorGUILayout.Space(); + EditorGUILayout.Separator(); + } + + /// + /// 绘制复制到包体内的资源组 + /// + private static void DrawCopyGroup() + { using (EditorGUILayout.ToggleGroupScope toggle = new EditorGUILayout.ToggleGroupScope("资源包构建目标平台只有1个时,在构建完成后将其复制到StreamingAssets目录下", BundleBuildConfigSO.Instance.IsCopyToReadOnlyDirectory)) @@ -142,14 +191,21 @@ public override void DrawSubWindow(Rect position) { using (new EditorGUILayout.HorizontalScope()) { - EditorGUILayout.LabelField("要复制的资源组(以分号分隔,为空则全部复制):",GUILayout.Width(300)); - BundleBuildConfigSO.Instance.CopyGroup = EditorGUILayout.TextField(BundleBuildConfigSO.Instance.CopyGroup,GUILayout.Width(600)); + EditorGUILayout.LabelField("要复制的资源组(以分号分隔,为空则全部复制):", GUILayout.Width(300)); + BundleBuildConfigSO.Instance.CopyGroup = + EditorGUILayout.TextField(BundleBuildConfigSO.Instance.CopyGroup, GUILayout.Width(600)); } } - - EditorGUILayout.Space(); - - var oldColor = GUI.color; + + EditorGUILayout.Separator(); + } + + /// + /// 绘制按钮 + /// + private void DrawButtons() + { + var oldColor = GUI.color; using (new EditorGUILayout.HorizontalScope()) { GUI.color = Color.red; @@ -224,12 +280,6 @@ public override void DrawSubWindow(Rect position) } GUI.color = oldColor; } - - if (EditorGUI.EndChangeCheck()) - { - EditorUtility.SetDirty(BundleBuildConfigSO.Instance); - AssetDatabase.SaveAssets(); - } } } } \ No newline at end of file