@@ -66,10 +66,11 @@ public virtual SerializedProperty DoInspectorGUI()
66
66
{
67
67
var fieldInfo = prop . Key . field ;
68
68
EditorGUI . BeginChangeCheck ( ) ;
69
- var attrs = fieldInfo . GetCustomAttributes ( typeof ( StringProviderAttribute ) , true ) ;
70
- if ( attrs . Length > 0 )
69
+ var stringAttribute = fieldInfo . GetCustomAttributes < StringProviderAttribute > ( true ) ;
70
+ var rangeAttribute = fieldInfo . GetCustomAttributes < RangeAttribute > ( false ) . FirstOrDefault ( ) ;
71
+ if ( stringAttribute . Any ( ) )
71
72
{
72
- var strings = StringPropertyRM . FindStringProvider ( attrs ) ( ) ;
73
+ var strings = StringPropertyRM . FindStringProvider ( stringAttribute . ToArray ( ) ) ( ) ;
73
74
74
75
int selected = prop . Value . hasMultipleDifferentValues ? - 1 : System . Array . IndexOf ( strings , prop . Value . stringValue ) ;
75
76
int result = EditorGUILayout . Popup ( ObjectNames . NicifyVariableName ( prop . Value . name ) , selected , strings ) ;
@@ -110,15 +111,14 @@ public virtual SerializedProperty DoInspectorGUI()
110
111
EditorGUILayout . IntPopup ( prop . Value , enumNames , enumValues ) ;
111
112
}
112
113
else if ( fieldInfo . FieldType == typeof ( int )
113
- && fieldInfo . GetCustomAttributes ( typeof ( RangeAttribute ) , false ) . Length != 0
114
- && fieldInfo . GetCustomAttributes ( typeof ( DelayedAttribute ) , false ) . Length != 0 )
114
+ && rangeAttribute != null
115
+ && fieldInfo . GetCustomAttributes < DelayedAttribute > ( ) . Any ( ) )
115
116
{
116
117
//Workaround: Range & Delayed attribute are incompatible, avoid the slider usage to keep the delayed behavior
117
118
var newValue = EditorGUILayout . DelayedIntField ( ObjectNames . NicifyVariableName ( prop . Value . name ) , prop . Value . intValue ) ;
118
119
if ( EditorGUI . EndChangeCheck ( ) )
119
120
{
120
- var delay = ( RangeAttribute ) fieldInfo . GetCustomAttributes ( typeof ( RangeAttribute ) , false ) . First ( ) ;
121
- newValue = Mathf . Clamp ( newValue , ( int ) delay . min , ( int ) delay . max ) ;
121
+ newValue = Mathf . Clamp ( newValue , ( int ) rangeAttribute . min , ( int ) rangeAttribute . max ) ;
122
122
prop . Value . intValue = newValue ;
123
123
modifiedSetting = prop . Value ;
124
124
}
0 commit comments