Skip to content

Commit 1bbdb82

Browse files
committed
Fix label overlapping button
By drawing the button later, the label won't overlap the button. This seems to be a bug with list renderings. The width is correctly calculated for the button, but somehow not applied in the list rendering (there seems to be a minsize for the button, but I didn't find the code that would enforce that)
1 parent 97c4e63 commit 1bbdb82

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,6 @@ public override void OnGUI (Rect position,SerializedProperty property,GUIContent
4141
popupPosition.x += EditorGUIUtility.labelWidth;
4242
popupPosition.height = EditorGUIUtility.singleLineHeight;
4343

44-
if (EditorGUI.DropdownButton(popupPosition,GetTypeName(property),FocusType.Keyboard)) {
45-
TypePopupCache popup = GetTypePopup(property);
46-
m_TargetProperty = property;
47-
popup.TypePopup.Show(popupPosition);
48-
}
49-
5044
// Check if a custom property drawer exists for this type.
5145
PropertyDrawer customDrawer = GetCustomPropertyDrawer(property);
5246
if (customDrawer != null)
@@ -72,6 +66,13 @@ public override void OnGUI (Rect position,SerializedProperty property,GUIContent
7266
{
7367
EditorGUI.PropertyField(position, property, label, true);
7468
}
69+
70+
// Draw button after label to avoid label overlap in list rendering
71+
if (EditorGUI.DropdownButton(popupPosition,GetTypeName(property),FocusType.Keyboard)) {
72+
TypePopupCache popup = GetTypePopup(property);
73+
m_TargetProperty = property;
74+
popup.TypePopup.Show(popupPosition);
75+
}
7576
} else {
7677
EditorGUI.LabelField(position,label,k_IsNotManagedReferenceLabel);
7778
}

0 commit comments

Comments
 (0)