diff --git a/Editor/Drawers/ReadableScriptableObjectAttributeDrawer.cs b/Editor/Drawers/ReadableScriptableObjectAttributeDrawer.cs index 5fe9e40..cb6f482 100644 --- a/Editor/Drawers/ReadableScriptableObjectAttributeDrawer.cs +++ b/Editor/Drawers/ReadableScriptableObjectAttributeDrawer.cs @@ -16,12 +16,11 @@ namespace Module.Inspector.Editor EditorGUI.BeginChangeCheck(); EditorGUI.BeginProperty(position, label, property); - { if (property.objectReferenceValue != null) { property.isExpanded = DrawFoldout(position, property, label); - + if (property.isExpanded) DrawContent(position, property.objectReferenceValue, att.editable); } @@ -44,7 +43,6 @@ namespace Module.Inspector.Editor property.objectReferenceValue = EditorGUI.ObjectField(rectObj, property.objectReferenceValue, property.GetValueType(), false); } } - EditorGUI.EndProperty(); bool hasChanged = EditorGUI.EndChangeCheck(); @@ -78,6 +76,11 @@ namespace Module.Inspector.Editor GUIStyle style = property.objectReferenceValue != null ? EditorStyles.foldoutHeader : EditorStyles.label; 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) { GUI.Toggle(position, foldout, label, style); @@ -88,6 +91,7 @@ namespace Module.Inspector.Editor property.objectReferenceValue = EditorGUI.ObjectField(rectObj, property.objectReferenceValue, property.GetValueType(), false); foldout = GUI.Toggle(position, foldout, label, style); } +#endif return foldout; } @@ -96,28 +100,28 @@ namespace Module.Inspector.Editor { var serializedObject = new SerializedObject(obj); SerializedProperty it = serializedObject.GetIterator(); - + it.NextVisible(true); rect.y += EditorGUIUtility.singleLineHeight; - + EditorGUI.indentLevel++; EditorGUI.BeginChangeCheck(); { bool prevEnabled = GUI.enabled; GUI.enabled = prevEnabled && editable; - + while (it.NextVisible(false)) { rect.height = EditorGUI.GetPropertyHeight(it); EditorGUI.PropertyField(rect, it, new GUIContent(it.displayName), true); rect.y += rect.height; } - + GUI.enabled = prevEnabled; } bool hasChanged = EditorGUI.EndChangeCheck(); EditorGUI.indentLevel--; - + if (hasChanged) serializedObject.ApplyModifiedProperties(); } diff --git a/package.json b/package.json index 0287006..e18408a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "com.module.inspector", - "version": "1.11.1", + "version": "1.11.2", "displayName": "Module.Inspector", "description": "Custom inspector with various useful property drawers", "unity": "2019.2",