From 7a458add5d169773ca904dc3a4e0a0d170cf15a6 Mon Sep 17 00:00:00 2001 From: mackysoft Date: Sat, 19 Aug 2023 21:28:14 +0900 Subject: [PATCH] Fix layout --- .../Editor/SubclassSelectorDrawer.cs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/Assets/MackySoft/MackySoft.SerializeReferenceExtensions/Editor/SubclassSelectorDrawer.cs b/Assets/MackySoft/MackySoft.SerializeReferenceExtensions/Editor/SubclassSelectorDrawer.cs index 6f38577..aba3b02 100644 --- a/Assets/MackySoft/MackySoft.SerializeReferenceExtensions/Editor/SubclassSelectorDrawer.cs +++ b/Assets/MackySoft/MackySoft.SerializeReferenceExtensions/Editor/SubclassSelectorDrawer.cs @@ -58,11 +58,11 @@ namespace MackySoft.SerializeReferenceExtensions.Editor if (property.isExpanded) { - using (new EditorGUI.IndentLevelScope(1)) + using (new EditorGUI.IndentLevelScope()) { - Rect indentedRect = EditorGUI.IndentedRect(position); + Rect indentedRect = position; float foldoutDifference = EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; - indentedRect.height -= foldoutDifference; + indentedRect.height = customDrawer.GetPropertyHeight(property, label); indentedRect.y += foldoutDifference; customDrawer.OnGUI(indentedRect, property, label); } @@ -162,7 +162,15 @@ namespace MackySoft.SerializeReferenceExtensions.Editor } public override float GetPropertyHeight (SerializedProperty property,GUIContent label) { - return EditorGUI.GetPropertyHeight(property,true); + PropertyDrawer customDrawer = GetCustomPropertyDrawer(property); + if (customDrawer != null) + { + return property.isExpanded ? EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing + customDrawer.GetPropertyHeight(property,label):EditorGUIUtility.singleLineHeight; + } + else + { + return property.isExpanded ? EditorGUI.GetPropertyHeight(property,true) : EditorGUIUtility.singleLineHeight; + } } }