Skip to content

Commit

Permalink
fix: add BeginProperty to AvatarObjectReferenceDrawer
Browse files Browse the repository at this point in the history
  • Loading branch information
Rerigferl authored and bdunderscore committed Jan 25, 2025
1 parent 3a94498 commit 3ceafb8
Showing 1 changed file with 22 additions and 14 deletions.
36 changes: 22 additions & 14 deletions Editor/Inspector/AvatarObjectReferenceDrawer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,28 @@ internal class AvatarObjectReferenceDrawer : PropertyDrawer
{
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
if (CustomGUI(position, property, label)) return;

var xButtonSize = EditorStyles.miniButtonRight.CalcSize(new GUIContent("x"));
var xButtonRect = new Rect(position.xMax - xButtonSize.x, position.y, xButtonSize.x, position.height);
position = new Rect(position.x, position.y, position.width - xButtonSize.x, position.height);

property = property.FindPropertyRelative(nameof(AvatarObjectReference.referencePath));

position = EditorGUI.PrefixLabel(position, label);

using (var scope = new ZeroIndentScope())
{
EditorGUI.LabelField(position,
string.IsNullOrEmpty(property.stringValue) ? "(null)" : property.stringValue);
label = EditorGUI.BeginProperty(position, label, property);
try
{
if (CustomGUI(position, property, label)) return;

var xButtonSize = EditorStyles.miniButtonRight.CalcSize(new GUIContent("x"));
var xButtonRect = new Rect(position.xMax - xButtonSize.x, position.y, xButtonSize.x, position.height);
position = new Rect(position.x, position.y, position.width - xButtonSize.x, position.height);

property = property.FindPropertyRelative(nameof(AvatarObjectReference.referencePath));

position = EditorGUI.PrefixLabel(position, label);

using (var scope = new ZeroIndentScope())
{
EditorGUI.LabelField(position,
string.IsNullOrEmpty(property.stringValue) ? "(null)" : property.stringValue);
}
}
finally
{
EditorGUI.EndProperty();
}
}

Expand Down

0 comments on commit 3ceafb8

Please sign in to comment.