@@ -10,6 +10,8 @@ namespace Toolbox.Editor.Drawers
1010
1111 public class ReferencePickerAttributeDrawer : ToolboxSelfPropertyDrawer < ReferencePickerAttribute >
1212 {
13+ private const float minTypeFieldWidth = 30.0f ;
14+
1315 private static readonly TypeConstraintContext sharedConstraint = new TypeConstraintReference ( null ) ;
1416 private static readonly TypeAppearanceContext sharedAppearance = new TypeAppearanceContext ( sharedConstraint , TypeGrouping . None , true ) ;
1517 private static readonly TypeField typeField = new TypeField ( sharedConstraint , sharedAppearance ) ;
@@ -20,11 +22,9 @@ private void UpdateContexts(ReferencePickerAttribute attribute)
2022 sharedAppearance . TypeGrouping = attribute . TypeGrouping ;
2123 }
2224
23- private void CreateTypeProperty ( SerializedProperty property , Type parentType )
25+ private void CreateTypeProperty ( Rect position , SerializedProperty property , Type parentType )
2426 {
2527 TypeUtilities . TryGetTypeFromManagedReferenceFullTypeName ( property . managedReferenceFullTypename , out var currentType ) ;
26- var position = EditorGUILayout . GetControlRect ( false , EditorGUIUtility . singleLineHeight ) ;
27- position = EditorGUI . IndentedRect ( position ) ;
2828 typeField . OnGui ( position , true , ( type ) =>
2929 {
3030 try
@@ -83,17 +83,24 @@ protected override void OnGuiSafe(SerializedProperty property, GUIContent label,
8383 {
8484 using ( var propertyScope = new PropertyScope ( property , label ) )
8585 {
86- if ( ! propertyScope . IsVisible )
87- {
88- return ;
89- }
90-
9186 UpdateContexts ( attribute ) ;
9287 var parentType = GetParentType ( property , attribute ) ;
93-
9488 EditorGUI . indentLevel ++ ;
95- CreateTypeProperty ( property , parentType ) ;
96- ToolboxEditorGui . DrawPropertyChildren ( property ) ;
89+
90+ var position = GUILayoutUtility . GetLastRect ( ) ;
91+ position . xMax = position . xMin + EditorGUIUtility . currentViewWidth ;
92+ var labelSize = EditorStyles . label . CalcSize ( label ) ;
93+ var x = Mathf . Max ( EditorGUIUtility . labelWidth , labelSize . x ) ;
94+ position . xMin = position . xMin + x ;
95+ //position = EditorGUILayout.GetControlRect(false, EditorGUIUtility.singleLineHeight);
96+ //position = EditorGUI.IndentedRect(position);
97+
98+ CreateTypeProperty ( position , property , parentType ) ;
99+ if ( propertyScope . IsVisible )
100+ {
101+ ToolboxEditorGui . DrawPropertyChildren ( property ) ;
102+ }
103+
97104 EditorGUI . indentLevel -- ;
98105 }
99106 }
0 commit comments