[bugfix]Convert the show name to the type name 把显示名字转换成类型名字

pull/53/head^2
ZensYue 2022-12-02 20:39:28 +08:00
parent aa49980231
commit 114ebab6ae
2 changed files with 38 additions and 3 deletions

View File

@ -102,6 +102,38 @@ namespace YooAsset.Editor
} }
return names; 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<string, System.Type> 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) public static bool HasActiveRuleName(string ruleName)
{ {
foreach (var pair in _cacheActiveRuleTypes) foreach (var pair in _cacheActiveRuleTypes)

View File

@ -700,7 +700,8 @@ namespace YooAsset.Editor
popupField1.index = GetAddressRuleIndex(collector.AddressRuleName); popupField1.index = GetAddressRuleIndex(collector.AddressRuleName);
popupField1.RegisterValueChangedCallback(evt => popupField1.RegisterValueChangedCallback(evt =>
{ {
collector.AddressRuleName = evt.newValue; var target = (PopupField<string>)evt.target;
collector.AddressRuleName = AssetBundleCollectorSettingData.GetAddressRuleName(target.index);
AssetBundleCollectorSettingData.ModifyCollector(selectGroup, collector); AssetBundleCollectorSettingData.ModifyCollector(selectGroup, collector);
if (foldout.value) if (foldout.value)
{ {
@ -714,7 +715,8 @@ namespace YooAsset.Editor
popupField2.index = GetPackRuleIndex(collector.PackRuleName); popupField2.index = GetPackRuleIndex(collector.PackRuleName);
popupField2.RegisterValueChangedCallback(evt => popupField2.RegisterValueChangedCallback(evt =>
{ {
collector.PackRuleName = evt.newValue; var target = (PopupField<string>)evt.target;
collector.PackRuleName = AssetBundleCollectorSettingData.GetPackRuleName(target.index);
AssetBundleCollectorSettingData.ModifyCollector(selectGroup, collector); AssetBundleCollectorSettingData.ModifyCollector(selectGroup, collector);
if (foldout.value) if (foldout.value)
{ {
@ -727,7 +729,8 @@ namespace YooAsset.Editor
popupField3.index = GetFilterRuleIndex(collector.FilterRuleName); popupField3.index = GetFilterRuleIndex(collector.FilterRuleName);
popupField3.RegisterValueChangedCallback(evt => popupField3.RegisterValueChangedCallback(evt =>
{ {
collector.FilterRuleName = evt.newValue; var target = (PopupField<string>)evt.target;
collector.FilterRuleName = AssetBundleCollectorSettingData.GetFilterRuleName(target.index);
AssetBundleCollectorSettingData.ModifyCollector(selectGroup, collector); AssetBundleCollectorSettingData.ModifyCollector(selectGroup, collector);
if (foldout.value) if (foldout.value)
{ {