From 3ceafb8e1f57b6e1d0facb790c26b5df4286e563 Mon Sep 17 00:00:00 2001 From: Rerigferl <70315656+AshleyScarlet@users.noreply.github.com> Date: Tue, 17 Dec 2024 17:07:52 +0900 Subject: [PATCH] fix: add BeginProperty to AvatarObjectReferenceDrawer --- .../Inspector/AvatarObjectReferenceDrawer.cs | 36 +++++++++++-------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/Editor/Inspector/AvatarObjectReferenceDrawer.cs b/Editor/Inspector/AvatarObjectReferenceDrawer.cs index 3543681e..fd63a708 100644 --- a/Editor/Inspector/AvatarObjectReferenceDrawer.cs +++ b/Editor/Inspector/AvatarObjectReferenceDrawer.cs @@ -8,20 +8,28 @@ namespace nadena.dev.modular_avatar.core.editor { 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(); } }