1.11.2: Fixed issue, where ReadableScriptableObject would block input to later drawn fields, due to Repaint having reverse drawing order (fixed for 6.3.0 or newer)

This commit is contained in:
Anders Ejlersen 2025-12-28 21:28:04 +01:00
parent f4c4a58283
commit 6e3bd4df70
2 changed files with 13 additions and 9 deletions

View file

@ -16,12 +16,11 @@ namespace Module.Inspector.Editor
EditorGUI.BeginChangeCheck(); EditorGUI.BeginChangeCheck();
EditorGUI.BeginProperty(position, label, property); EditorGUI.BeginProperty(position, label, property);
{ {
if (property.objectReferenceValue != null) if (property.objectReferenceValue != null)
{ {
property.isExpanded = DrawFoldout(position, property, label); property.isExpanded = DrawFoldout(position, property, label);
if (property.isExpanded) if (property.isExpanded)
DrawContent(position, property.objectReferenceValue, att.editable); DrawContent(position, property.objectReferenceValue, att.editable);
} }
@ -44,7 +43,6 @@ namespace Module.Inspector.Editor
property.objectReferenceValue = EditorGUI.ObjectField(rectObj, property.objectReferenceValue, property.GetValueType(), false); property.objectReferenceValue = EditorGUI.ObjectField(rectObj, property.objectReferenceValue, property.GetValueType(), false);
} }
} }
EditorGUI.EndProperty(); EditorGUI.EndProperty();
bool hasChanged = EditorGUI.EndChangeCheck(); bool hasChanged = EditorGUI.EndChangeCheck();
@ -78,6 +76,11 @@ namespace Module.Inspector.Editor
GUIStyle style = property.objectReferenceValue != null ? EditorStyles.foldoutHeader : EditorStyles.label; GUIStyle style = property.objectReferenceValue != null ? EditorStyles.foldoutHeader : EditorStyles.label;
bool foldout = property.isExpanded; bool foldout = property.isExpanded;
#if UNITY_6000_3_OR_NEWER
position.width = rectObj.x - position.x;
foldout = GUI.Toggle(position, foldout, label, style);
property.objectReferenceValue = EditorGUI.ObjectField(rectObj, property.objectReferenceValue, property.GetValueType(), false);
#else
if (Event.current.type == EventType.Repaint) if (Event.current.type == EventType.Repaint)
{ {
GUI.Toggle(position, foldout, label, style); GUI.Toggle(position, foldout, label, style);
@ -88,6 +91,7 @@ namespace Module.Inspector.Editor
property.objectReferenceValue = EditorGUI.ObjectField(rectObj, property.objectReferenceValue, property.GetValueType(), false); property.objectReferenceValue = EditorGUI.ObjectField(rectObj, property.objectReferenceValue, property.GetValueType(), false);
foldout = GUI.Toggle(position, foldout, label, style); foldout = GUI.Toggle(position, foldout, label, style);
} }
#endif
return foldout; return foldout;
} }
@ -96,28 +100,28 @@ namespace Module.Inspector.Editor
{ {
var serializedObject = new SerializedObject(obj); var serializedObject = new SerializedObject(obj);
SerializedProperty it = serializedObject.GetIterator(); SerializedProperty it = serializedObject.GetIterator();
it.NextVisible(true); it.NextVisible(true);
rect.y += EditorGUIUtility.singleLineHeight; rect.y += EditorGUIUtility.singleLineHeight;
EditorGUI.indentLevel++; EditorGUI.indentLevel++;
EditorGUI.BeginChangeCheck(); EditorGUI.BeginChangeCheck();
{ {
bool prevEnabled = GUI.enabled; bool prevEnabled = GUI.enabled;
GUI.enabled = prevEnabled && editable; GUI.enabled = prevEnabled && editable;
while (it.NextVisible(false)) while (it.NextVisible(false))
{ {
rect.height = EditorGUI.GetPropertyHeight(it); rect.height = EditorGUI.GetPropertyHeight(it);
EditorGUI.PropertyField(rect, it, new GUIContent(it.displayName), true); EditorGUI.PropertyField(rect, it, new GUIContent(it.displayName), true);
rect.y += rect.height; rect.y += rect.height;
} }
GUI.enabled = prevEnabled; GUI.enabled = prevEnabled;
} }
bool hasChanged = EditorGUI.EndChangeCheck(); bool hasChanged = EditorGUI.EndChangeCheck();
EditorGUI.indentLevel--; EditorGUI.indentLevel--;
if (hasChanged) if (hasChanged)
serializedObject.ApplyModifiedProperties(); serializedObject.ApplyModifiedProperties();
} }

View file

@ -1,6 +1,6 @@
{ {
"name": "com.module.inspector", "name": "com.module.inspector",
"version": "1.11.1", "version": "1.11.2",
"displayName": "Module.Inspector", "displayName": "Module.Inspector",
"description": "Custom inspector with various useful property drawers", "description": "Custom inspector with various useful property drawers",
"unity": "2019.2", "unity": "2019.2",