fix: add BeginProperty to AvatarObjectReferenceDrawer

This commit is contained in:
Rerigferl 2024-12-17 17:07:52 +09:00
parent cca9e22edd
commit ad9d9019c5
No known key found for this signature in database

View File

@ -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();
}
}