Skip to content

Commit 4ea6aba

Browse files
lejeanfclaude
andcommitted
fix(drawer): align ScriptableObject object field with standard fields (1.2.3)
The object-field rect omitted position.x (the inspector margin), so every [ScriptableObjectDrawer] field drew ~18px left of standard property fields. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 394101c commit 4ea6aba

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

Runtime/Editor/ScriptableObjectDrawer.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,12 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten
110110
property.isExpanded = false;
111111
}
112112

113-
// Draw the object field
113+
// Draw the object field. The rect must be offset by position.x (the inspector margin),
114+
// otherwise the field lands ~18px left of every standard field and breaks column alignment.
114115
const int offset = 2;
115116
EditorGUI.BeginChangeCheck();
116117
EditorGUI.PropertyField(
117-
new Rect(EditorGUIUtility.labelWidth + offset, position.y,
118+
new Rect(position.x + EditorGUIUtility.labelWidth + offset, position.y,
118119
position.width - EditorGUIUtility.labelWidth - offset, EditorGUIUtility.singleLineHeight),
119120
property, GUIContent.none, true);
120121

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name":"fr.jeanf.propertydrawer",
3-
"version":"1.2.2",
3+
"version":"1.2.3",
44
"displayName":"Property drawer",
55
"description":"This package helps hiding certain properties from the inspector using conditions",
66
"unity": "2021.3",

0 commit comments

Comments
 (0)