Skip to content

Commit e153ee7

Browse files
committed
Minor refactor changes
1 parent d42e47a commit e153ee7

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

Assets/Editor Toolbox/Editor/Drawers/Toolbox/PropertySelf/ReferencePickerAttributeDrawer.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace Toolbox.Editor.Drawers
1010

1111
public class ReferencePickerAttributeDrawer : ToolboxSelfPropertyDrawer<ReferencePickerAttribute>
1212
{
13-
private const float minLabelWidth = 100.0f;
13+
private const float neededLabelWidth = 100.0f;
1414
private const float labelWidthOffset = -80.0f;
1515

1616
private static readonly TypeConstraintContext sharedConstraint = new TypeConstraintReference(null);
@@ -80,23 +80,24 @@ private void UpdateTypeProperty(SerializedProperty property, Type referenceType)
8080
property.serializedObject.ApplyModifiedProperties();
8181
}
8282

83-
private Rect CreateTypePropertyPosition(in Rect labelPosition, in Rect inputPosition, bool isPropertyExpanded)
83+
private Rect PrepareTypePropertyPosition(in Rect labelPosition, in Rect inputPosition, bool isPropertyExpanded)
8484
{
8585
var position = new Rect(inputPosition);
8686
var baseLabelWidth = EditorGUIUtility.labelWidth + labelWidthOffset;
8787
var realLabelWidth = labelPosition.width;
8888
var labelWidth = Mathf.Max(baseLabelWidth, realLabelWidth);
8989
if (isPropertyExpanded)
9090
{
91-
//NOTE: property is expanded and we have place to move it to the next row
92-
if (labelWidth < minLabelWidth)
91+
//property is expanded and we have place to move it to the next row
92+
if (labelWidth < neededLabelWidth)
9393
{
9494
position = EditorGUILayout.GetControlRect(false, EditorGUIUtility.singleLineHeight);
9595
position = EditorGUI.IndentedRect(position);
9696
return position;
9797
}
9898
}
9999

100+
//adjust position to already rendered label
100101
position.xMin += labelWidth;
101102
return position;
102103
}
@@ -112,7 +113,7 @@ protected override void OnGuiSafe(SerializedProperty property, GUIContent label,
112113
EditorGUI.indentLevel++;
113114
var labelRect = propertyScope.LabelRect;
114115
var inputRect = propertyScope.InputRect;
115-
var position = CreateTypePropertyPosition(in labelRect, in inputRect, isPropertyExpanded);
116+
var position = PrepareTypePropertyPosition(in labelRect, in inputRect, isPropertyExpanded);
116117

117118
var parentType = GetParentType(property, attribute);
118119
CreateTypeProperty(position, property, parentType);

0 commit comments

Comments
 (0)