From 114ebab6ae7fb34c411a1ce822bb25c0b0e79cb6 Mon Sep 17 00:00:00 2001 From: ZensYue Date: Fri, 2 Dec 2022 20:39:28 +0800 Subject: [PATCH] =?UTF-8?q?[bugfix]Convert=20the=20show=20name=20to=20the?= =?UTF-8?q?=20type=20name=20=E6=8A=8A=E6=98=BE=E7=A4=BA=E5=90=8D=E5=AD=97?= =?UTF-8?q?=E8=BD=AC=E6=8D=A2=E6=88=90=E7=B1=BB=E5=9E=8B=E5=90=8D=E5=AD=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AssetBundleCollectorSettingData.cs | 32 +++++++++++++++++++ .../AssetBundleCollectorWindow.cs | 9 ++++-- 2 files changed, 38 insertions(+), 3 deletions(-) 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) {