Fix: InlineField attribute not working

This commit is contained in:
AnnulusGames 2024-02-17 15:00:00 +09:00
parent f6526b3cc1
commit c463f36882

View File

@ -3,6 +3,7 @@ using UnityEngine.Assertions;
using UnityEngine.UIElements;
using UnityEditor;
using UnityEditor.UIElements;
using Alchemy.Inspector;
namespace Alchemy.Editor.Elements
{
@ -29,19 +30,31 @@ namespace Alchemy.Editor.Elements
foldout.BindProperty(property);
field = GUIHelper.CreateObjectPropertyField(property, type);
field = new ObjectField()
{
label = ObjectNames.NicifyVariableName(property.displayName),
objectType = type,
allowSceneObjects = property.GetFieldInfo().HasCustomAttribute<AssetsOnlyAttribute>(),
value = property.objectReferenceValue
};
field.style.position = Position.Absolute;
field.style.width = Length.Percent(100f);
GUIHelper.ScheduleAdjustLabelWidth(field);
// OnPropertyChanged(property);
field.RegisterValueChangeCallback(x => OnPropertyChanged(x.changedProperty));
OnPropertyChanged(property);
field.RegisterValueChangedCallback(x =>
{
property.objectReferenceValue = x.newValue;
property.serializedObject.ApplyModifiedProperties();
OnPropertyChanged(property);
});
Add(foldout);
Add(field);
}
readonly Foldout foldout;
readonly PropertyField field;
readonly ObjectField field;
readonly int depth;
bool isNull;