Skip to content

Commit 7dacea5

Browse files
FIx minor issue
Resolve #5646 (comment) Resolve #5646 (comment)
1 parent 8f7cc14 commit 7dacea5

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

com.unity.visualeffectgraph/Editor/Inspector/VFXSlotContainerEditor.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,11 @@ public virtual SerializedProperty DoInspectorGUI()
6666
{
6767
var fieldInfo = prop.Key.field;
6868
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())
7172
{
72-
var strings = StringPropertyRM.FindStringProvider(attrs)();
73+
var strings = StringPropertyRM.FindStringProvider(stringAttribute.ToArray())();
7374

7475
int selected = prop.Value.hasMultipleDifferentValues ? -1 : System.Array.IndexOf(strings, prop.Value.stringValue);
7576
int result = EditorGUILayout.Popup(ObjectNames.NicifyVariableName(prop.Value.name), selected, strings);
@@ -110,15 +111,14 @@ public virtual SerializedProperty DoInspectorGUI()
110111
EditorGUILayout.IntPopup(prop.Value, enumNames, enumValues);
111112
}
112113
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())
115116
{
116117
//Workaround: Range & Delayed attribute are incompatible, avoid the slider usage to keep the delayed behavior
117118
var newValue = EditorGUILayout.DelayedIntField(ObjectNames.NicifyVariableName(prop.Value.name), prop.Value.intValue);
118119
if (EditorGUI.EndChangeCheck())
119120
{
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);
122122
prop.Value.intValue = newValue;
123123
modifiedSetting = prop.Value;
124124
}

0 commit comments

Comments
 (0)