Skip to content

Commit 7a458ad

Browse files
committed
Fix layout
1 parent 80b67bc commit 7a458ad

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

Assets/MackySoft/MackySoft.SerializeReferenceExtensions/Editor/SubclassSelectorDrawer.cs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,11 @@ public override void OnGUI (Rect position,SerializedProperty property,GUIContent
5858

5959
if (property.isExpanded)
6060
{
61-
using (new EditorGUI.IndentLevelScope(1))
61+
using (new EditorGUI.IndentLevelScope())
6262
{
63-
Rect indentedRect = EditorGUI.IndentedRect(position);
63+
Rect indentedRect = position;
6464
float foldoutDifference = EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
65-
indentedRect.height -= foldoutDifference;
65+
indentedRect.height = customDrawer.GetPropertyHeight(property, label);
6666
indentedRect.y += foldoutDifference;
6767
customDrawer.OnGUI(indentedRect, property, label);
6868
}
@@ -162,7 +162,15 @@ GUIContent GetTypeName (SerializedProperty property) {
162162
}
163163

164164
public override float GetPropertyHeight (SerializedProperty property,GUIContent label) {
165-
return EditorGUI.GetPropertyHeight(property,true);
165+
PropertyDrawer customDrawer = GetCustomPropertyDrawer(property);
166+
if (customDrawer != null)
167+
{
168+
return property.isExpanded ? EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing + customDrawer.GetPropertyHeight(property,label):EditorGUIUtility.singleLineHeight;
169+
}
170+
else
171+
{
172+
return property.isExpanded ? EditorGUI.GetPropertyHeight(property,true) : EditorGUIUtility.singleLineHeight;
173+
}
166174
}
167175

168176
}

0 commit comments

Comments
 (0)