Skip to content

Commit c9b5193

Browse files
committed
Fix use prefixLabel position right away
1 parent a8bcece commit c9b5193

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

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

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,14 @@ public override void OnGUI (Rect position,SerializedProperty property,GUIContent
3535
EditorGUI.BeginProperty(position,label,property);
3636

3737
if (property.propertyType == SerializedPropertyType.ManagedReference) {
38-
38+
3939
// render label first to avoid label overlap for lists
4040
Rect foldoutLabelRect = new Rect(position);
4141
foldoutLabelRect.height = EditorGUIUtility.singleLineHeight;
4242
foldoutLabelRect.x += EditorGUI.indentLevel * 12;
43-
EditorGUI.PrefixLabel(foldoutLabelRect, label);
44-
45-
// Draw the subclass selector popup.
46-
Rect popupPosition = new Rect(position);
47-
popupPosition.width -= EditorGUIUtility.labelWidth;
48-
popupPosition.x += EditorGUIUtility.labelWidth;
49-
popupPosition.height = EditorGUIUtility.singleLineHeight;
43+
Rect popupPosition = EditorGUI.PrefixLabel(foldoutLabelRect, label);
5044

45+
// Draw the subclass selector popup.
5146
if (EditorGUI.DropdownButton(popupPosition,GetTypeName(property),FocusType.Keyboard)) {
5247
TypePopupCache popup = GetTypePopup(property);
5348
m_TargetProperty = property;
@@ -62,7 +57,7 @@ public override void OnGUI (Rect position,SerializedProperty property,GUIContent
6257
Rect foldoutRect = new Rect(position);
6358
foldoutRect.height = EditorGUIUtility.singleLineHeight;
6459
property.isExpanded = EditorGUI.Foldout(foldoutRect, property.isExpanded, GUIContent.none, true);
65-
60+
6661
if (property.isExpanded)
6762
{
6863
using (new EditorGUI.IndentLevelScope())
@@ -102,7 +97,7 @@ TypePopupCache GetTypePopup (SerializedProperty property) {
10297

10398
if (!m_TypePopups.TryGetValue(managedReferenceFieldTypename,out TypePopupCache result)) {
10499
var state = new AdvancedDropdownState();
105-
100+
106101
Type baseType = ManagedReferenceUtility.GetType(managedReferenceFieldTypename);
107102
var popup = new AdvancedTypePopup(
108103
TypeCache.GetTypesDerivedFrom(baseType).Append(baseType).Where(p =>
@@ -125,7 +120,7 @@ TypePopupCache GetTypePopup (SerializedProperty property) {
125120

126121
object obj = individualProperty.SetManagedReference(type);
127122
individualProperty.isExpanded = (obj != null);
128-
123+
129124
individualObject.ApplyModifiedProperties();
130125
individualObject.Update();
131126
}

0 commit comments

Comments
 (0)