diff --git a/Megumin.UnityPackage/Packages/megumin.explosion4unity/Runtime/Scripts/NewClass/Attribute/NewButtonAttribute.cs b/Megumin.UnityPackage/Packages/megumin.explosion4unity/Runtime/Scripts/NewClass/Attribute/NewButtonAttribute.cs index c05b6cd..fd32f54 100644 --- a/Megumin.UnityPackage/Packages/megumin.explosion4unity/Runtime/Scripts/NewClass/Attribute/NewButtonAttribute.cs +++ b/Megumin.UnityPackage/Packages/megumin.explosion4unity/Runtime/Scripts/NewClass/Attribute/NewButtonAttribute.cs @@ -275,6 +275,11 @@ protected void DrawReference(SerializedProperty property, GUIContent label, Rect } } } + else + { + index = 0; + SelectedIndex[indexCacheKey] = 0; + } } var oldSelectedIndex = index; @@ -581,8 +586,7 @@ public void CacheSupportType(SerializedProperty property) if (property.propertyType == SerializedPropertyType.ManagedReference) { - //一般类型,因为没办法设置为null,在下拉菜单中最后加入null类型,用于清空当前值 - int index = 0; + SupportNames = new string[allTypes.Count + 1]; SupportTypes = new Type[allTypes.Count + 1]; @@ -591,6 +595,12 @@ public void CacheSupportType(SerializedProperty property) var indexCacheKey = (property.serializedObject.targetObject, property.propertyPath, property.managedReferenceValue); SelectedIndex[indexCacheKey] = allTypes.Count; + //一般类型,因为没办法设置为null,在下拉菜单中第一项加入null类型,用于清空当前值 + int index = 0; + SupportNames[index] = "Null"; + SupportTypes[index] = null; + index++; + foreach (var item in allTypes) { SupportNames[index] = item.Name; @@ -602,9 +612,6 @@ public void CacheSupportType(SerializedProperty property) } index++; } - - SupportNames[allTypes.Count] = "Null"; - SupportTypes[allTypes.Count] = null; } else {