From aa49980231ea9ea61e2d7cfb209af76ae9f24ded Mon Sep 17 00:00:00 2001 From: ZensYue Date: Fri, 2 Dec 2022 12:31:15 +0800 Subject: [PATCH 1/2] =?UTF-8?q?[add]Add=20ShowEditorAlias=20=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E6=98=BE=E7=A4=BA=E7=BC=96=E8=BE=91=E5=99=A8=E5=90=8D?= =?UTF-8?q?=E5=AD=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AssetBundleCollectorConfig.cs | 5 ++ .../AssetBundleCollectorSetting.cs | 6 ++ .../AssetBundleCollectorSettingData.cs | 32 +++++++++-- .../AssetBundleCollectorWindow.cs | 36 +++++++++--- .../AssetBundleCollectorWindow.uxml | 1 + .../DefaultAddressRule.cs | 3 + .../AssetBundleCollector/DefaultFilterRule.cs | 7 ++- .../AssetBundleCollector/DefaultPackRule.cs | 7 +++ Assets/YooAsset/Editor/YooAssetAttributes.cs | 55 +++++++++++++++++++ .../Editor/YooAssetAttributes.cs.meta | 11 ++++ 10 files changed, 148 insertions(+), 15 deletions(-) create mode 100644 Assets/YooAsset/Editor/YooAssetAttributes.cs create mode 100644 Assets/YooAsset/Editor/YooAssetAttributes.cs.meta diff --git a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorConfig.cs b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorConfig.cs index ba880ef..7e9b039 100644 --- a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorConfig.cs +++ b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorConfig.cs @@ -17,6 +17,7 @@ namespace YooAsset.Editor public const string XmlEnableAddressable = "AutoAddressable"; public const string XmlUniqueBundleName = "UniqueBundleName"; public const string XmlShowPackageView = "ShowPackageView"; + public const string XmlShowEditorAlias = "ShowEditorAlias"; public const string XmlPackage = "Package"; public const string XmlPackageName = "PackageName"; @@ -65,6 +66,7 @@ namespace YooAsset.Editor bool enableAddressable = false; bool uniqueBundleName = false; bool showPackageView = false; + bool showEditorAlias = false; var commonNodeList = root.GetElementsByTagName(XmlCommon); if (commonNodeList.Count > 0) { @@ -79,6 +81,7 @@ namespace YooAsset.Editor enableAddressable = commonElement.GetAttribute(XmlEnableAddressable) == "True" ? true : false; uniqueBundleName = commonElement.GetAttribute(XmlUniqueBundleName) == "True" ? true : false; showPackageView = commonElement.GetAttribute(XmlShowPackageView) == "True" ? true : false; + showEditorAlias = commonElement.GetAttribute(XmlShowEditorAlias) == "True" ? true : false; } // 读取包裹配置 @@ -153,6 +156,7 @@ namespace YooAsset.Editor AssetBundleCollectorSettingData.Setting.EnableAddressable = enableAddressable; AssetBundleCollectorSettingData.Setting.UniqueBundleName = uniqueBundleName; AssetBundleCollectorSettingData.Setting.ShowPackageView = showPackageView; + AssetBundleCollectorSettingData.Setting.ShowEditorAlias = showEditorAlias; AssetBundleCollectorSettingData.Setting.Packages.AddRange(packages); AssetBundleCollectorSettingData.SaveFile(); Debug.Log($"导入配置完毕!"); @@ -183,6 +187,7 @@ namespace YooAsset.Editor commonElement.SetAttribute(XmlEnableAddressable, AssetBundleCollectorSettingData.Setting.EnableAddressable.ToString()); commonElement.SetAttribute(XmlUniqueBundleName, AssetBundleCollectorSettingData.Setting.UniqueBundleName.ToString()); commonElement.SetAttribute(XmlShowPackageView, AssetBundleCollectorSettingData.Setting.ShowPackageView.ToString()); + commonElement.SetAttribute(XmlShowEditorAlias, AssetBundleCollectorSettingData.Setting.ShowEditorAlias.ToString()); root.AppendChild(commonElement); // 设置Package配置 diff --git a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorSetting.cs b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorSetting.cs index 9f4223c..bfcc7d8 100644 --- a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorSetting.cs +++ b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorSetting.cs @@ -23,6 +23,12 @@ namespace YooAsset.Editor /// public bool UniqueBundleName = false; + /// + /// 是否显示编辑器别名 + /// + public bool ShowEditorAlias = false; + + /// /// 包裹列表 /// diff --git a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorSettingData.cs b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorSettingData.cs index bacceb5..4510313 100644 --- a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorSettingData.cs +++ b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorSettingData.cs @@ -38,6 +38,22 @@ namespace YooAsset.Editor } } + private static string GetEditorShowName(string name,Type type) + { + if (Setting != null && Setting.ShowEditorAlias) + { + var attr = YooAssetAttributes.GetAttribute(type); + if (attr != null && !string.IsNullOrEmpty(attr.Name)) + return attr.Name; + else + return name; + } + else + { + return name; + } + } + public static List GetActiveRuleNames() { if (_setting == null) @@ -47,8 +63,8 @@ namespace YooAsset.Editor foreach (var pair in _cacheActiveRuleTypes) { names.Add(pair.Key); - } - return names; + } + return names; } public static List GetAddressRuleNames() { @@ -58,7 +74,7 @@ namespace YooAsset.Editor List names = new List(); foreach (var pair in _cacheAddressRuleTypes) { - names.Add(pair.Key); + names.Add(GetEditorShowName(pair.Key, pair.Value)); } return names; } @@ -70,7 +86,7 @@ namespace YooAsset.Editor List names = new List(); foreach (var pair in _cachePackRuleTypes) { - names.Add(pair.Key); + names.Add(GetEditorShowName(pair.Key, pair.Value)); } return names; } @@ -82,7 +98,7 @@ namespace YooAsset.Editor List names = new List(); foreach (var pair in _cacheFilterRuleTypes) { - names.Add(pair.Key); + names.Add(GetEditorShowName(pair.Key, pair.Value)); } return names; } @@ -353,6 +369,12 @@ namespace YooAsset.Editor IsDirty = true; } + public static void ModifyShowEditorAlias(bool showAlias) + { + Setting.ShowEditorAlias = showAlias; + IsDirty = true; + } + // 资源包裹编辑相关 public static AssetBundleCollectorPackage CreatePackage(string packageName) { diff --git a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorWindow.cs b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorWindow.cs index 8be6013..154d8f4 100644 --- a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorWindow.cs +++ b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorWindow.cs @@ -28,6 +28,7 @@ namespace YooAsset.Editor private Toggle _showPackageToogle; private Toggle _enableAddressableToogle; private Toggle _uniqueBundleNameToogle; + private Toggle _showEditorAliasToggle; private VisualElement _packageContainer; private ListView _packageListView; @@ -57,14 +58,12 @@ namespace YooAsset.Editor { _collectorTypeList = new List() { - $"{nameof(ECollectorType.MainAssetCollector)}", - $"{nameof(ECollectorType.StaticAssetCollector)}", - $"{nameof(ECollectorType.DependAssetCollector)}" - }; - _activeRuleList = AssetBundleCollectorSettingData.GetActiveRuleNames(); - _addressRuleList = AssetBundleCollectorSettingData.GetAddressRuleNames(); - _packRuleList = AssetBundleCollectorSettingData.GetPackRuleNames(); - _filterRuleList = AssetBundleCollectorSettingData.GetFilterRuleNames(); + $"{nameof(ECollectorType.MainAssetCollector)}", + $"{nameof(ECollectorType.StaticAssetCollector)}", + $"{nameof(ECollectorType.DependAssetCollector)}" + }; + + RefreshNames(); VisualElement root = this.rootVisualElement; @@ -95,6 +94,14 @@ namespace YooAsset.Editor RefreshWindow(); }); + _showEditorAliasToggle = root.Q("ShowEditorAlias"); + _showEditorAliasToggle.RegisterValueChangedCallback(evt => + { + AssetBundleCollectorSettingData.ModifyShowEditorAlias(evt.newValue); + RefreshNames(); + RefreshWindow(); + }); + // 配置修复按钮 var fixBtn = root.Q