Skip to content

Commit 7e1e589

Browse files
committed
Fit LabelRect width to label and recalculate text and button position based on new rect
1 parent ff2ac9d commit 7e1e589

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

Packages/com.unity.inputsystem/InputSystem/Editor/ControlPicker/InputControlPathEditor.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,18 +96,17 @@ public void OnGUI(Rect rect, GUIContent label = null, SerializedProperty propert
9696

9797
var lineRect = rect;
9898
var labelRect = lineRect;
99-
labelRect.width = EditorGUIUtility.labelWidth;
99+
labelRect.width = EditorStyles.label.CalcSize(pathLabel).x + 20; // Fit to label with some padding
100100
EditorGUI.LabelField(labelRect, pathLabel);
101101
lineRect.x += labelRect.width;
102102
lineRect.width -= labelRect.width;
103103

104104
var bindingTextRect = lineRect;
105105
var editButtonRect = lineRect;
106106

107-
var bindingTextRectOffset = 80;
108-
bindingTextRect.width += bindingTextRectOffset;
109-
bindingTextRect.x -= bindingTextRectOffset + 20;
110-
editButtonRect.x = bindingTextRect.x + bindingTextRect.width; // Place it directly after the textRect
107+
bindingTextRect.x = labelRect.x + labelRect.width; // Place directly after labelRect
108+
editButtonRect.x += lineRect.width - 20; // Place at the edge of the window to appear after bindingTextRect
109+
bindingTextRect.width = editButtonRect.x - bindingTextRect.x; // bindingTextRect fills remaining space between label and editButton
111110
editButtonRect.width = 20;
112111
editButtonRect.height = 15;
113112

0 commit comments

Comments
 (0)