diff --git a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorSettingData.cs b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorSettingData.cs index 4510313..3b7ceac 100644 --- a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorSettingData.cs +++ b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorSettingData.cs @@ -102,6 +102,38 @@ namespace YooAsset.Editor } 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) diff --git a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorWindow.cs b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorWindow.cs index 154d8f4..0ee46c9 100644 --- a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorWindow.cs +++ b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorWindow.cs @@ -700,7 +700,8 @@ namespace YooAsset.Editor popupField1.index = GetAddressRuleIndex(collector.AddressRuleName); popupField1.RegisterValueChangedCallback(evt => { - collector.AddressRuleName = evt.newValue; + var target = (PopupField)evt.target; + collector.AddressRuleName = AssetBundleCollectorSettingData.GetAddressRuleName(target.index); AssetBundleCollectorSettingData.ModifyCollector(selectGroup, collector); if (foldout.value) { @@ -714,7 +715,8 @@ namespace YooAsset.Editor popupField2.index = GetPackRuleIndex(collector.PackRuleName); popupField2.RegisterValueChangedCallback(evt => { - collector.PackRuleName = evt.newValue; + var target = (PopupField)evt.target; + collector.PackRuleName = AssetBundleCollectorSettingData.GetPackRuleName(target.index); AssetBundleCollectorSettingData.ModifyCollector(selectGroup, collector); if (foldout.value) { @@ -727,7 +729,8 @@ namespace YooAsset.Editor popupField3.index = GetFilterRuleIndex(collector.FilterRuleName); popupField3.RegisterValueChangedCallback(evt => { - collector.FilterRuleName = evt.newValue; + var target = (PopupField)evt.target; + collector.FilterRuleName = AssetBundleCollectorSettingData.GetFilterRuleName(target.index); AssetBundleCollectorSettingData.ModifyCollector(selectGroup, collector); if (foldout.value) {