@@ -80,12 +80,16 @@ private void UpdateTypeProperty(SerializedProperty property, Type referenceType)
8080 property . serializedObject . ApplyModifiedProperties ( ) ;
8181 }
8282
83- private Rect PrepareTypePropertyPosition ( in Rect labelPosition , in Rect inputPosition , bool isPropertyExpanded )
83+ private Rect PrepareTypePropertyPosition ( bool hasLabel , in Rect labelPosition , in Rect inputPosition , bool isPropertyExpanded )
8484 {
8585 var position = new Rect ( inputPosition ) ;
86- var baseLabelWidth = EditorGUIUtility . labelWidth + labelWidthOffset ;
87- var realLabelWidth = labelPosition . width ;
88- var labelWidth = Mathf . Max ( baseLabelWidth , realLabelWidth ) ;
86+ if ( ! hasLabel )
87+ {
88+ position . xMin += EditorGUIUtility . standardVerticalSpacing ;
89+ return position ;
90+ }
91+
92+ //skip row only if label exists
8993 if ( isPropertyExpanded )
9094 {
9195 //property is expanded and we have place to move it to the next row
@@ -94,23 +98,28 @@ private Rect PrepareTypePropertyPosition(in Rect labelPosition, in Rect inputPos
9498 return position ;
9599 }
96100
101+ var baseLabelWidth = EditorGUIUtility . labelWidth + labelWidthOffset ;
102+ var realLabelWidth = labelPosition . width ;
97103 //adjust position to already rendered label
98- position . xMin += labelWidth ;
104+ position . xMin += Mathf . Max ( baseLabelWidth , realLabelWidth ) ;
99105 return position ;
100106 }
101107
102108
103109 protected override void OnGuiSafe ( SerializedProperty property , GUIContent label , ReferencePickerAttribute attribute )
104110 {
105- using ( var propertyScope = new PropertyScope ( property , label ) )
111+ //NOTE: we want to close scope manually because ExitGUIException can interrupt drawing and SerializedProperties stack
112+ using ( var propertyScope = new PropertyScope ( property , label , closeManually : true ) )
106113 {
107114 UpdateContexts ( attribute ) ;
108115
109116 var isPropertyExpanded = propertyScope . IsVisible ;
110117 EditorGUI . indentLevel ++ ;
111118 var labelRect = propertyScope . LabelRect ;
112119 var inputRect = propertyScope . InputRect ;
113- var position = PrepareTypePropertyPosition ( in labelRect , in inputRect , isPropertyExpanded ) ;
120+
121+ var hasLabel = ! string . IsNullOrEmpty ( label . text ) ;
122+ var position = PrepareTypePropertyPosition ( hasLabel , in labelRect , in inputRect , isPropertyExpanded ) ;
114123
115124 var parentType = GetParentType ( property , attribute ) ;
116125 CreateTypeProperty ( position , property , parentType ) ;
@@ -120,6 +129,7 @@ protected override void OnGuiSafe(SerializedProperty property, GUIContent label,
120129 }
121130
122131 EditorGUI . indentLevel -- ;
132+ propertyScope . Close ( ) ;
123133 }
124134 }
125135
0 commit comments