diff --git a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorConfig.cs b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorConfig.cs index 7e9b039..6558d8d 100644 --- a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorConfig.cs +++ b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorConfig.cs @@ -10,7 +10,7 @@ namespace YooAsset.Editor { public class AssetBundleCollectorConfig { - public const string ConfigVersion = "2.1"; + public const string ConfigVersion = "2.2"; public const string XmlVersion = "Version"; public const string XmlCommon = "Common"; @@ -77,6 +77,8 @@ namespace YooAsset.Editor throw new Exception($"Not found attribute {XmlUniqueBundleName} in {XmlCommon}"); if (commonElement.HasAttribute(XmlShowPackageView) == false) throw new Exception($"Not found attribute {XmlShowPackageView} in {XmlCommon}"); + if (commonElement.HasAttribute(XmlShowEditorAlias) == false) + throw new Exception($"Not found attribute {XmlShowEditorAlias} in {XmlCommon}"); enableAddressable = commonElement.GetAttribute(XmlEnableAddressable) == "True" ? true : false; uniqueBundleName = commonElement.GetAttribute(XmlUniqueBundleName) == "True" ? true : false; @@ -301,6 +303,23 @@ namespace YooAsset.Editor return UpdateXmlConfig(xmlDoc); } + // 2.1 -> 2.2 + if (configVersion == "2.1") + { + // 添加公共元素属性 + var commonNodeList = root.GetElementsByTagName(XmlCommon); + if (commonNodeList.Count > 0) + { + XmlElement commonElement = commonNodeList[0] as XmlElement; + if (commonElement.HasAttribute(XmlShowEditorAlias) == false) + commonElement.SetAttribute(XmlShowEditorAlias, "False"); + } + + // 更新版本 + root.SetAttribute(XmlVersion, "2.2"); + return UpdateXmlConfig(xmlDoc); + } + return false; } } diff --git a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorSettingData.cs b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorSettingData.cs index 3b7ceac..55600c4 100644 --- a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorSettingData.cs +++ b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorSettingData.cs @@ -38,140 +38,6 @@ 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) - LoadSettingData(); - - List names = new List(); - foreach (var pair in _cacheActiveRuleTypes) - { - names.Add(pair.Key); - } - return names; - } - public static List GetAddressRuleNames() - { - if (_setting == null) - LoadSettingData(); - - List names = new List(); - foreach (var pair in _cacheAddressRuleTypes) - { - names.Add(GetEditorShowName(pair.Key, pair.Value)); - } - return names; - } - public static List GetPackRuleNames() - { - if (_setting == null) - LoadSettingData(); - - List names = new List(); - foreach (var pair in _cachePackRuleTypes) - { - names.Add(GetEditorShowName(pair.Key, pair.Value)); - } - return names; - } - public static List GetFilterRuleNames() - { - if (_setting == null) - LoadSettingData(); - - List names = new List(); - foreach (var pair in _cacheFilterRuleTypes) - { - names.Add(GetEditorShowName(pair.Key, pair.Value)); - } - return names; - } - - public static string GetAddressRuleName(int index) - { - if (_setting == null) - LoadSettingData(); - return GetTypesName(_cacheAddressRuleTypes, index); - } - - public static string GetPackRuleName(int index) - { - if (_setting == null) - LoadSettingData(); - return GetTypesName(_cachePackRuleTypes, index); - } - - public static string GetFilterRuleName(int index) - { - if (_setting == null) - LoadSettingData(); - return GetTypesName(_cacheFilterRuleTypes, index); - } - - static string GetTypesName(Dictionary types, int index) - { - - if(index >= types.Keys.Count) - { - throw new Exception($"Invalid GetFilterRuleName Keys.Count {types.Keys.Count} : try get index {index}"); - } - return types.Keys.ElementAt(index); - } - - public static bool HasActiveRuleName(string ruleName) - { - foreach (var pair in _cacheActiveRuleTypes) - { - if (pair.Key == ruleName) - return true; - } - return false; - } - public static bool HasAddressRuleName(string ruleName) - { - foreach (var pair in _cacheAddressRuleTypes) - { - if (pair.Key == ruleName) - return true; - } - return false; - } - public static bool HasPackRuleName(string ruleName) - { - foreach (var pair in _cachePackRuleTypes) - { - if (pair.Key == ruleName) - return true; - } - return false; - } - public static bool HasFilterRuleName(string ruleName) - { - foreach (var pair in _cacheFilterRuleTypes) - { - if (pair.Key == ruleName) - return true; - } - return false; - } - - /// /// 加载配置文件 /// @@ -194,6 +60,7 @@ namespace YooAsset.Editor typeof(PackCollector), typeof(PackGroup), typeof(PackRawFile), + typeof(PackShaderVariants) }; var customTypes = EditorTools.GetAssignableTypes(typeof(IPackRule)); @@ -314,7 +181,92 @@ namespace YooAsset.Editor SaveFile(); } - // 实例类相关 + public static List GetActiveRuleNames() + { + if (_setting == null) + LoadSettingData(); + + List names = new List(); + foreach (var pair in _cacheActiveRuleTypes) + { + RuleDisplayName ruleName = new RuleDisplayName(); + ruleName.ClassName = pair.Key; + ruleName.DisplayName = GetRuleDisplayName(pair.Key, pair.Value); + names.Add(ruleName); + } + return names; + } + public static List GetAddressRuleNames() + { + if (_setting == null) + LoadSettingData(); + + List names = new List(); + foreach (var pair in _cacheAddressRuleTypes) + { + RuleDisplayName ruleName = new RuleDisplayName(); + ruleName.ClassName = pair.Key; + ruleName.DisplayName = GetRuleDisplayName(pair.Key, pair.Value); + names.Add(ruleName); + } + return names; + } + public static List GetPackRuleNames() + { + if (_setting == null) + LoadSettingData(); + + List names = new List(); + foreach (var pair in _cachePackRuleTypes) + { + RuleDisplayName ruleName = new RuleDisplayName(); + ruleName.ClassName = pair.Key; + ruleName.DisplayName = GetRuleDisplayName(pair.Key, pair.Value); + names.Add(ruleName); + } + return names; + } + public static List GetFilterRuleNames() + { + if (_setting == null) + LoadSettingData(); + + List names = new List(); + foreach (var pair in _cacheFilterRuleTypes) + { + RuleDisplayName ruleName = new RuleDisplayName(); + ruleName.ClassName = pair.Key; + ruleName.DisplayName = GetRuleDisplayName(pair.Key, pair.Value); + names.Add(ruleName); + } + return names; + } + private static string GetRuleDisplayName(string name, Type type) + { + var attribute = EditorAttribute.GetAttribute(type); + if (attribute != null && string.IsNullOrEmpty(attribute.DisplayName) == false) + return attribute.DisplayName; + else + return name; + } + + public static bool HasActiveRuleName(string ruleName) + { + return _cacheActiveRuleTypes.Keys.Contains(ruleName); + } + public static bool HasAddressRuleName(string ruleName) + { + return _cacheAddressRuleTypes.Keys.Contains(ruleName); + } + public static bool HasPackRuleName(string ruleName) + { + return _cachePackRuleTypes.Keys.Contains(ruleName); + } + public static bool HasFilterRuleName(string ruleName) + { + return _cacheFilterRuleTypes.Keys.Contains(ruleName); + } + public static IActiveRule GetActiveRuleInstance(string ruleName) { if (_cacheActiveRuleInstance.TryGetValue(ruleName, out IActiveRule instance)) @@ -400,7 +352,6 @@ namespace YooAsset.Editor Setting.UniqueBundleName = uniqueBundleName; IsDirty = true; } - public static void ModifyShowEditorAlias(bool showAlias) { Setting.ShowEditorAlias = showAlias; diff --git a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorWindow.cs b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorWindow.cs index 0ee46c9..ec5ea68 100644 --- a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorWindow.cs +++ b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorWindow.cs @@ -20,11 +20,11 @@ namespace YooAsset.Editor private Button _saveButton; private List _collectorTypeList; - private List _activeRuleList; - private List _addressRuleList; - private List _packRuleList; - private List _filterRuleList; - + private List _activeRuleList; + private List _addressRuleList; + private List _packRuleList; + private List _filterRuleList; + private Toggle _showPackageToogle; private Toggle _enableAddressableToogle; private Toggle _uniqueBundleNameToogle; @@ -43,7 +43,7 @@ namespace YooAsset.Editor private VisualElement _collectorContainer; private ScrollView _collectorScrollView; - private PopupField _activeRulePopupField; + private PopupField _activeRulePopupField; private int _lastModifyPackageIndex = 0; private int _lastModifyGroupIndex = 0; @@ -58,12 +58,14 @@ namespace YooAsset.Editor { _collectorTypeList = new List() { - $"{nameof(ECollectorType.MainAssetCollector)}", - $"{nameof(ECollectorType.StaticAssetCollector)}", - $"{nameof(ECollectorType.DependAssetCollector)}" - }; - - RefreshNames(); + $"{nameof(ECollectorType.MainAssetCollector)}", + $"{nameof(ECollectorType.StaticAssetCollector)}", + $"{nameof(ECollectorType.DependAssetCollector)}" + }; + _activeRuleList = AssetBundleCollectorSettingData.GetActiveRuleNames(); + _addressRuleList = AssetBundleCollectorSettingData.GetAddressRuleNames(); + _packRuleList = AssetBundleCollectorSettingData.GetPackRuleNames(); + _filterRuleList = AssetBundleCollectorSettingData.GetFilterRuleNames(); VisualElement root = this.rootVisualElement; @@ -98,7 +100,6 @@ namespace YooAsset.Editor _showEditorAliasToggle.RegisterValueChangedCallback(evt => { AssetBundleCollectorSettingData.ModifyShowEditorAlias(evt.newValue); - RefreshNames(); RefreshWindow(); }); @@ -243,21 +244,23 @@ namespace YooAsset.Editor // 分组激活规则 var activeRuleContainer = root.Q("ActiveRuleContainer"); { - _activeRulePopupField = new PopupField("Active Rule", _activeRuleList, 0); + _activeRulePopupField = new PopupField("Active Rule", _activeRuleList, 0); _activeRulePopupField.name = "ActiveRuleMaskField"; _activeRulePopupField.style.unityTextAlign = TextAnchor.MiddleLeft; - activeRuleContainer.Add(_activeRulePopupField); + _activeRulePopupField.formatListItemCallback = FormatListItemCallback; + _activeRulePopupField.formatSelectedValueCallback = FormatSelectedValueCallback; _activeRulePopupField.RegisterValueChangedCallback(evt => { var selectPackage = _packageListView.selectedItem as AssetBundleCollectorPackage; var selectGroup = _groupListView.selectedItem as AssetBundleCollectorGroup; if (selectPackage != null && selectGroup != null) { - selectGroup.ActiveRuleName = evt.newValue; + selectGroup.ActiveRuleName = evt.newValue.ClassName; AssetBundleCollectorSettingData.ModifyGroup(selectPackage, selectGroup); FillGroupViewData(); } }); + activeRuleContainer.Add(_activeRulePopupField); } // 刷新窗体 @@ -293,14 +296,6 @@ namespace YooAsset.Editor } } - private void RefreshNames() - { - _activeRuleList = AssetBundleCollectorSettingData.GetActiveRuleNames(); - _addressRuleList = AssetBundleCollectorSettingData.GetAddressRuleNames(); - _packRuleList = AssetBundleCollectorSettingData.GetPackRuleNames(); - _filterRuleList = AssetBundleCollectorSettingData.GetFilterRuleNames(); - } - private void RefreshWindow() { _showPackageToogle.SetValueWithoutNotify(AssetBundleCollectorSettingData.Setting.ShowPackageView); @@ -339,6 +334,20 @@ namespace YooAsset.Editor { AssetBundleCollectorSettingData.SaveFile(); } + private string FormatListItemCallback(RuleDisplayName ruleDisplayName) + { + if (_showEditorAliasToggle.value) + return ruleDisplayName.DisplayName; + else + return ruleDisplayName.ClassName; + } + private string FormatSelectedValueCallback(RuleDisplayName ruleDisplayName) + { + if (_showEditorAliasToggle.value) + return ruleDisplayName.DisplayName; + else + return ruleDisplayName.ClassName; + } // 包裹列表相关 private void FillPackageViewData() @@ -352,7 +361,7 @@ namespace YooAsset.Editor { _packageListView.selectedIndex = _lastModifyPackageIndex; } - + if (_showPackageToogle.value) _packageContainer.style.display = DisplayStyle.Flex; else @@ -428,7 +437,7 @@ namespace YooAsset.Editor _groupListView.itemsSource = selectPackage.Groups; _groupListView.Rebuild(); - if(_lastModifyGroupIndex >=0 && _lastModifyGroupIndex < _groupListView.itemsSource.Count) + if (_lastModifyGroupIndex >= 0 && _lastModifyGroupIndex < _groupListView.itemsSource.Count) { _groupListView.selectedIndex = _lastModifyGroupIndex; } @@ -478,7 +487,7 @@ namespace YooAsset.Editor _collectorContainer.visible = true; _lastModifyGroupIndex = _groupListView.selectedIndex; - _activeRulePopupField.SetValueWithoutNotify(selectGroup.ActiveRuleName); + _activeRulePopupField.SetValueWithoutNotify(GetActiveRuleIndex(selectGroup.ActiveRuleName)); _groupNameTxt.SetValueWithoutNotify(selectGroup.GroupName); _groupDescTxt.SetValueWithoutNotify(selectGroup.GroupDesc); _groupAssetTagsTxt.SetValueWithoutNotify(selectGroup.AssetTags); @@ -582,21 +591,21 @@ namespace YooAsset.Editor } if (_enableAddressableToogle.value) { - var popupField = new PopupField(_addressRuleList, 0); + var popupField = new PopupField(_addressRuleList, 0); popupField.name = "PopupField1"; popupField.style.unityTextAlign = TextAnchor.MiddleLeft; popupField.style.width = 200; elementBottom.Add(popupField); } { - var popupField = new PopupField(_packRuleList, 0); + var popupField = new PopupField(_packRuleList, 0); popupField.name = "PopupField2"; popupField.style.unityTextAlign = TextAnchor.MiddleLeft; popupField.style.width = 230; elementBottom.Add(popupField); } { - var popupField = new PopupField(_filterRuleList, 0); + var popupField = new PopupField(_filterRuleList, 0); popupField.name = "PopupField3"; popupField.style.unityTextAlign = TextAnchor.MiddleLeft; popupField.style.width = 150; @@ -694,14 +703,15 @@ namespace YooAsset.Editor }); // Address Rule - var popupField1 = element.Q>("PopupField1"); + var popupField1 = element.Q>("PopupField1"); if (popupField1 != null) { popupField1.index = GetAddressRuleIndex(collector.AddressRuleName); + popupField1.formatListItemCallback = FormatListItemCallback; + popupField1.formatSelectedValueCallback = FormatSelectedValueCallback; popupField1.RegisterValueChangedCallback(evt => { - var target = (PopupField)evt.target; - collector.AddressRuleName = AssetBundleCollectorSettingData.GetAddressRuleName(target.index); + collector.AddressRuleName = evt.newValue.ClassName; AssetBundleCollectorSettingData.ModifyCollector(selectGroup, collector); if (foldout.value) { @@ -711,12 +721,13 @@ namespace YooAsset.Editor } // Pack Rule - var popupField2 = element.Q>("PopupField2"); + var popupField2 = element.Q>("PopupField2"); popupField2.index = GetPackRuleIndex(collector.PackRuleName); + popupField2.formatListItemCallback = FormatListItemCallback; + popupField2.formatSelectedValueCallback = FormatSelectedValueCallback; popupField2.RegisterValueChangedCallback(evt => { - var target = (PopupField)evt.target; - collector.PackRuleName = AssetBundleCollectorSettingData.GetPackRuleName(target.index); + collector.PackRuleName = evt.newValue.ClassName; AssetBundleCollectorSettingData.ModifyCollector(selectGroup, collector); if (foldout.value) { @@ -725,12 +736,13 @@ namespace YooAsset.Editor }); // Filter Rule - var popupField3 = element.Q>("PopupField3"); + var popupField3 = element.Q>("PopupField3"); popupField3.index = GetFilterRuleIndex(collector.FilterRuleName); + popupField3.formatListItemCallback = FormatListItemCallback; + popupField3.formatSelectedValueCallback = FormatSelectedValueCallback; popupField3.RegisterValueChangedCallback(evt => { - var target = (PopupField)evt.target; - collector.FilterRuleName = AssetBundleCollectorSettingData.GetFilterRuleName(target.index); + collector.FilterRuleName = evt.newValue.ClassName; AssetBundleCollectorSettingData.ModifyCollector(selectGroup, collector); if (foldout.value) { @@ -836,7 +848,7 @@ namespace YooAsset.Editor { for (int i = 0; i < _addressRuleList.Count; i++) { - if (_addressRuleList[i] == ruleName) + if (_addressRuleList[i].ClassName == ruleName) return i; } return 0; @@ -845,7 +857,7 @@ namespace YooAsset.Editor { for (int i = 0; i < _packRuleList.Count; i++) { - if (_packRuleList[i] == ruleName) + if (_packRuleList[i].ClassName == ruleName) return i; } return 0; @@ -854,11 +866,20 @@ namespace YooAsset.Editor { for (int i = 0; i < _filterRuleList.Count; i++) { - if (_filterRuleList[i] == ruleName) + if (_filterRuleList[i].ClassName == ruleName) return i; } return 0; } + private RuleDisplayName GetActiveRuleIndex(string ruleName) + { + for (int i = 0; i < _activeRuleList.Count; i++) + { + if (_activeRuleList[i].ClassName == ruleName) + return _activeRuleList[i]; + } + return _activeRuleList[0]; + } } } #endif \ No newline at end of file diff --git a/Assets/YooAsset/Editor/AssetBundleCollector/DefaultActiveRule.cs b/Assets/YooAsset/Editor/AssetBundleCollector/DefaultActiveRule.cs index 9a6b6a6..3538031 100644 --- a/Assets/YooAsset/Editor/AssetBundleCollector/DefaultActiveRule.cs +++ b/Assets/YooAsset/Editor/AssetBundleCollector/DefaultActiveRule.cs @@ -1,9 +1,7 @@  namespace YooAsset.Editor { - /// - /// 启用分组 - /// + [DisplayName("启用分组")] public class EnableGroup : IActiveRule { public bool IsActiveGroup() @@ -12,9 +10,7 @@ namespace YooAsset.Editor } } - /// - /// 禁用分组 - /// + [DisplayName("禁用分组")] public class DisableGroup : IActiveRule { public bool IsActiveGroup() diff --git a/Assets/YooAsset/Editor/AssetBundleCollector/DefaultAddressRule.cs b/Assets/YooAsset/Editor/AssetBundleCollector/DefaultAddressRule.cs index 7bdd826..a2f1936 100644 --- a/Assets/YooAsset/Editor/AssetBundleCollector/DefaultAddressRule.cs +++ b/Assets/YooAsset/Editor/AssetBundleCollector/DefaultAddressRule.cs @@ -2,10 +2,7 @@ namespace YooAsset.Editor { - /// - /// 以文件名为定位地址 - /// - [EditorShow("以文件名为定位地址")] + [DisplayName("以文件名称为定位地址")] public class AddressByFileName : IAddressRule { string IAddressRule.GetAssetAddress(AddressRuleData data) @@ -14,10 +11,7 @@ namespace YooAsset.Editor } } - /// - /// 以组名+文件名为定位地址 - /// - [EditorShow("以组名+文件名为定位地址")] + [DisplayName("以分组名称+文件名称为定位地址")] public class AddressByGroupAndFileName : IAddressRule { string IAddressRule.GetAssetAddress(AddressRuleData data) @@ -27,10 +21,7 @@ namespace YooAsset.Editor } } - /// - /// 以收集器名+文件名为定位地址 - /// - [EditorShow("以收集器名+文件名为定位地址")] + [DisplayName("以收集器名称+文件名称为定位地址")] public class AddressByCollectorAndFileName : IAddressRule { string IAddressRule.GetAssetAddress(AddressRuleData data) diff --git a/Assets/YooAsset/Editor/AssetBundleCollector/DefaultFilterRule.cs b/Assets/YooAsset/Editor/AssetBundleCollector/DefaultFilterRule.cs index 156d33d..eba9b87 100644 --- a/Assets/YooAsset/Editor/AssetBundleCollector/DefaultFilterRule.cs +++ b/Assets/YooAsset/Editor/AssetBundleCollector/DefaultFilterRule.cs @@ -4,10 +4,7 @@ using System.IO; namespace YooAsset.Editor { - /// - /// 收集所有资源 - /// - [EditorShow("收集所有资源")] + [DisplayName("收集所有资源")] public class CollectAll : IFilterRule { public bool IsCollectAsset(FilterRuleData data) @@ -16,10 +13,7 @@ namespace YooAsset.Editor } } - /// - /// 只收集场景 - /// - [EditorShow("只收集场景")] + [DisplayName("收集场景")] public class CollectScene : IFilterRule { public bool IsCollectAsset(FilterRuleData data) @@ -28,10 +22,7 @@ namespace YooAsset.Editor } } - /// - /// 只收集预制体 - /// - [EditorShow("只收集预制体")] + [DisplayName("收集预制体")] public class CollectPrefab : IFilterRule { public bool IsCollectAsset(FilterRuleData data) @@ -40,16 +31,13 @@ namespace YooAsset.Editor } } - /// - /// 只收集精灵类型的资源 - /// - [EditorShow("只收集精灵类型的资源")] + [DisplayName("收集精灵类型的纹理")] public class CollectSprite : IFilterRule { public bool IsCollectAsset(FilterRuleData data) { var mainAssetType = AssetDatabase.GetMainAssetTypeAtPath(data.AssetPath); - if(mainAssetType == typeof(Texture2D)) + if (mainAssetType == typeof(Texture2D)) { var texImporter = AssetImporter.GetAtPath(data.AssetPath) as TextureImporter; if (texImporter != null && texImporter.textureType == TextureImporterType.Sprite) @@ -64,10 +52,7 @@ namespace YooAsset.Editor } } - /// - /// 只收集着色器变种收集文件 - /// - [EditorShow("只收集着色器变种收集文件")] + [DisplayName("收集着色器变种集合")] public class CollectShaderVariants : IFilterRule { public bool IsCollectAsset(FilterRuleData data) diff --git a/Assets/YooAsset/Editor/AssetBundleCollector/DefaultPackRule.cs b/Assets/YooAsset/Editor/AssetBundleCollector/DefaultPackRule.cs index 6ebd529..0304a27 100644 --- a/Assets/YooAsset/Editor/AssetBundleCollector/DefaultPackRule.cs +++ b/Assets/YooAsset/Editor/AssetBundleCollector/DefaultPackRule.cs @@ -10,7 +10,7 @@ namespace YooAsset.Editor /// 例如:"Assets/UIPanel/Shop/Image/backgroud.png" --> "assets_uipanel_shop_image_backgroud.bundle" /// 例如:"Assets/UIPanel/Shop/View/main.prefab" --> "assets_uipanel_shop_view_main.bundle" /// - [EditorShow("以文件路径作为资源包名")] + [DisplayName("以文件路径作为资源包名")] public class PackSeparately : IPackRule { string IPackRule.GetBundleName(PackRuleData data) @@ -26,7 +26,7 @@ namespace YooAsset.Editor /// 例如:"Assets/UIPanel/Shop/Image/backgroud.png" --> "assets_uipanel_shop_image.bundle" /// 例如:"Assets/UIPanel/Shop/View/main.prefab" --> "assets_uipanel_shop_view.bundle" /// - [EditorShow("以父类文件夹路径作为资源包名")] + [DisplayName("以父类文件夹路径作为资源包名")] public class PackDirectory : IPackRule { public static PackDirectory StaticPackRule = new PackDirectory(); @@ -45,7 +45,7 @@ namespace YooAsset.Editor /// 例如:"Assets/UIPanel/Shop/Image/backgroud.png" --> "assets_uipanel_shop.bundle" /// 例如:"Assets/UIPanel/Shop/View/main.prefab" --> "assets_uipanel_shop.bundle" /// - [EditorShow("以收集器路径下顶级文件夹为资源包名")] + [DisplayName("以收集器路径下顶级文件夹为资源包名")] public class PackTopDirectory : IPackRule { string IPackRule.GetBundleName(PackRuleData data) @@ -71,7 +71,7 @@ namespace YooAsset.Editor /// 以收集器路径作为资源包名 /// 注意:收集的所有文件打进一个资源包 /// - [EditorShow("以收集器路径作为资源包名")] + [DisplayName("以收集器路径作为资源包名")] public class PackCollector : IPackRule { string IPackRule.GetBundleName(PackRuleData data) @@ -94,7 +94,7 @@ namespace YooAsset.Editor /// 以分组名称作为资源包名 /// 注意:收集的所有文件打进一个资源包 /// - [EditorShow("以分组名称作为资源包名")] + [DisplayName("以分组名称作为资源包名")] public class PackGroup : IPackRule { string IPackRule.GetBundleName(PackRuleData data) @@ -104,10 +104,10 @@ namespace YooAsset.Editor } /// - /// 原生文件打包模式 + /// 打包原生文件 /// 注意:原生文件打包支持:图片,音频,视频,文本 /// - [EditorShow("原生文件打包模式")] + [DisplayName("打包原生文件")] public class PackRawFile : IPackRule { string IPackRule.GetBundleName(PackRuleData data) @@ -132,9 +132,9 @@ namespace YooAsset.Editor } /// - /// 着色器变种收集文件 + /// 打包着色器变种集合 /// - [EditorShow("着色器变种收集文件")] + [DisplayName("打包着色器变种集合")] public class PackShaderVariants : IPackRule { public string GetBundleName(PackRuleData data) diff --git a/Assets/YooAsset/Editor/AssetBundleCollector/RuleDisplayName.cs b/Assets/YooAsset/Editor/AssetBundleCollector/RuleDisplayName.cs new file mode 100644 index 0000000..885c150 --- /dev/null +++ b/Assets/YooAsset/Editor/AssetBundleCollector/RuleDisplayName.cs @@ -0,0 +1,9 @@ + +namespace YooAsset.Editor +{ + public class RuleDisplayName + { + public string ClassName; + public string DisplayName; + } +} \ No newline at end of file diff --git a/Assets/YooAsset/Editor/AssetBundleCollector/RuleDisplayName.cs.meta b/Assets/YooAsset/Editor/AssetBundleCollector/RuleDisplayName.cs.meta new file mode 100644 index 0000000..acb4843 --- /dev/null +++ b/Assets/YooAsset/Editor/AssetBundleCollector/RuleDisplayName.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: df712711c3830af419b7ada8fee53dda +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/YooAsset/Editor/EditorAttribute.cs b/Assets/YooAsset/Editor/EditorAttribute.cs new file mode 100644 index 0000000..beecd80 --- /dev/null +++ b/Assets/YooAsset/Editor/EditorAttribute.cs @@ -0,0 +1,36 @@ +using System; +using System.Reflection; + +namespace YooAsset.Editor +{ + /// + /// 编辑器显示名字 + /// + public class DisplayNameAttribute : Attribute + { + public string DisplayName; + + public DisplayNameAttribute(string name) + { + this.DisplayName = name; + } + } + + public static class EditorAttribute + { + internal static T GetAttribute(Type type) where T : Attribute + { + return (T)type.GetCustomAttribute(typeof(T), false); + } + + internal static T GetAttribute(MethodInfo methodInfo) where T : Attribute + { + return (T)methodInfo.GetCustomAttribute(typeof(T), false); + } + + internal static T GetAttribute(FieldInfo field) where T : Attribute + { + return (T)field.GetCustomAttribute(typeof(T), false); + } + } +} \ No newline at end of file diff --git a/Assets/YooAsset/Editor/YooAssetAttributes.cs.meta b/Assets/YooAsset/Editor/EditorAttribute.cs.meta similarity index 100% rename from Assets/YooAsset/Editor/YooAssetAttributes.cs.meta rename to Assets/YooAsset/Editor/EditorAttribute.cs.meta diff --git a/Assets/YooAsset/Editor/YooAssetAttributes.cs b/Assets/YooAsset/Editor/YooAssetAttributes.cs deleted file mode 100644 index 64ec5a2..0000000 --- a/Assets/YooAsset/Editor/YooAssetAttributes.cs +++ /dev/null @@ -1,55 +0,0 @@ -using System; -using System.Reflection; - -namespace YooAsset.Editor -{ - /// - /// ༭ʾ - /// - internal sealed class EditorShowAttribute : Attribute - { - public string Name; - public EditorShowAttribute(string name) - { - this.Name = name; - } - } - - internal static class YooAssetAttributes - { - /// - /// ȡ Type - /// - /// - /// - /// Ϊ - internal static T GetAttribute(Type type) where T : Attribute - { - return (T)type.GetCustomAttribute(typeof(T), false); - } - - /// - /// ȡ MethodInfo - /// - /// - /// - /// Ϊ - internal static T GetAttribute(MethodInfo methodInfo) where T : Attribute - { - return (T)methodInfo.GetCustomAttribute(typeof(T), false); - } - - /// - /// ȡ FieldInfo - /// - /// - /// - /// Ϊ - internal static T GetAttribute(FieldInfo field) where T : Attribute - { - return (T)field.GetCustomAttribute(typeof(T), false); - } - - - } -}