mirror of
https://github.com/AnnulusGames/Alchemy.git
synced 2025-01-22 08:18:51 -05:00
Merge pull request #26 from AnnulusGames/fix-inlinefield
Fix: [InlineField] not working
This commit is contained in:
commit
2035c6b37c
@ -30,12 +30,12 @@ namespace Alchemy.Editor.Elements
|
||||
}
|
||||
else
|
||||
{
|
||||
element = GUIHelper.CreateObjectField(property, type);
|
||||
element = GUIHelper.CreateObjectPropertyField(property, type);
|
||||
}
|
||||
break;
|
||||
case SerializedPropertyType.Generic:
|
||||
var targetType = property.GetPropertyType(isArrayElement);
|
||||
|
||||
|
||||
if (InternalAPIHelper.GetDrawerTypeForType(targetType) != null)
|
||||
{
|
||||
element = new PropertyField(property);
|
||||
|
@ -3,6 +3,7 @@ using UnityEngine.Assertions;
|
||||
using UnityEngine.UIElements;
|
||||
using UnityEditor;
|
||||
using UnityEditor.UIElements;
|
||||
using Alchemy.Inspector;
|
||||
|
||||
namespace Alchemy.Editor.Elements
|
||||
{
|
||||
@ -29,14 +30,23 @@ namespace Alchemy.Editor.Elements
|
||||
|
||||
foldout.BindProperty(property);
|
||||
|
||||
field = GUIHelper.CreateObjectField(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);
|
||||
|
||||
field.schedule.Execute(() =>
|
||||
OnPropertyChanged(property);
|
||||
field.RegisterValueChangedCallback(x =>
|
||||
{
|
||||
property.objectReferenceValue = x.newValue;
|
||||
property.serializedObject.ApplyModifiedProperties();
|
||||
OnPropertyChanged(property);
|
||||
field.RegisterValueChangeCallback(x => OnPropertyChanged(x.changedProperty));
|
||||
});
|
||||
|
||||
Add(foldout);
|
||||
@ -44,7 +54,7 @@ namespace Alchemy.Editor.Elements
|
||||
}
|
||||
|
||||
readonly Foldout foldout;
|
||||
readonly PropertyField field;
|
||||
readonly ObjectField field;
|
||||
readonly int depth;
|
||||
bool isNull;
|
||||
|
||||
|
@ -51,7 +51,7 @@ namespace Alchemy.Editor
|
||||
};
|
||||
}
|
||||
|
||||
public static PropertyField CreateObjectField(SerializedProperty property, Type type)
|
||||
public static PropertyField CreateObjectPropertyField(SerializedProperty property, Type type)
|
||||
{
|
||||
Assert.IsTrue(property.propertyType == SerializedPropertyType.ObjectReference);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user