Skip to content

Commit dea4233

Browse files
ganawarevalyard
authored andcommitted
Fixed the value being unchangeable from infinity when there are multiple inspectores
1 parent 74f5cb7 commit dea4233

1 file changed

Lines changed: 17 additions & 12 deletions

File tree

Source/Assets/TouchScript/Editor/Utils/PropertyDrawers/NullToggleDrawer.cs

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,23 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten
2626
updateExpanded(property);
2727

2828
EditorGUIUtility.labelWidth = 60;
29-
Begin(position, property, label);
29+
bool expandedChanged = Begin(position, property, label);
3030
if (expanded == false)
3131
{
32-
switch (property.propertyType)
32+
if (expandedChanged)
3333
{
34-
case SerializedPropertyType.ObjectReference:
35-
property.objectReferenceValue = (Object) getNullValue(property);
36-
break;
37-
case SerializedPropertyType.Integer:
38-
property.intValue = (int) getNullValue(property);
39-
break;
40-
case SerializedPropertyType.Float:
41-
property.floatValue = (float) getNullValue(property);
42-
break;
34+
switch (property.propertyType)
35+
{
36+
case SerializedPropertyType.ObjectReference:
37+
property.objectReferenceValue = (Object) getNullValue(property);
38+
break;
39+
case SerializedPropertyType.Integer:
40+
property.intValue = (int) getNullValue(property);
41+
break;
42+
case SerializedPropertyType.Float:
43+
property.floatValue = (float) getNullValue(property);
44+
break;
45+
}
4346
}
4447
}
4548
else
@@ -134,13 +137,15 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten
134137
// }
135138
}
136139

137-
private void Begin(Rect position, SerializedProperty property, GUIContent label)
140+
private bool Begin(Rect position, SerializedProperty property, GUIContent label)
138141
{
139142
label = EditorGUI.BeginProperty(position, label, property);
140143
label.text = " " + label.text;
141144
position.height = 16;
142145
EditorGUIUtility.labelWidth = 180;
146+
EditorGUI.BeginChangeCheck();
143147
expanded = EditorGUI.ToggleLeft(position, label, expanded == true);
148+
return EditorGUI.EndChangeCheck();
144149
}
145150

146151
private void End()

0 commit comments

Comments
 (0)