mirror of
https://github.com/AnnulusGames/Alchemy.git
synced 2025-01-22 08:18:51 -05:00
Fix: InlineEditor attribute doesn't work for arrays
This commit is contained in:
parent
2ee52ae93b
commit
4031a41822
@ -15,6 +15,8 @@ namespace Alchemy.Editor.Elements
|
|||||||
{
|
{
|
||||||
Assert.IsTrue(property.propertyType == SerializedPropertyType.ObjectReference);
|
Assert.IsTrue(property.propertyType == SerializedPropertyType.ObjectReference);
|
||||||
|
|
||||||
|
this.depth = depth;
|
||||||
|
|
||||||
style.minHeight = EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
style.minHeight = EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
|
||||||
foldout = new Foldout()
|
foldout = new Foldout()
|
||||||
@ -31,30 +33,19 @@ namespace Alchemy.Editor.Elements
|
|||||||
field.style.position = Position.Absolute;
|
field.style.position = Position.Absolute;
|
||||||
field.style.width = Length.Percent(100f);
|
field.style.width = Length.Percent(100f);
|
||||||
|
|
||||||
field.RegisterValueChangeCallback(x =>
|
field.schedule.Execute(() =>
|
||||||
{
|
{
|
||||||
isNull = x.changedProperty.objectReferenceValue == null;
|
OnPropertyChanged(property);
|
||||||
|
field.RegisterValueChangeCallback(x => OnPropertyChanged(x.changedProperty));
|
||||||
field.Q<Label>().text = isNull ? ObjectNames.NicifyVariableName(property.displayName) : string.Empty;
|
|
||||||
field.pickingMode = PickingMode.Ignore;
|
|
||||||
|
|
||||||
var objectField = field.Q<ObjectField>();
|
|
||||||
objectField.pickingMode = PickingMode.Ignore;
|
|
||||||
|
|
||||||
var label = objectField.Q<Label>();
|
|
||||||
label.pickingMode = PickingMode.Ignore;
|
|
||||||
|
|
||||||
Build(x.changedProperty, depth);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
Add(foldout);
|
Add(foldout);
|
||||||
Add(field);
|
Add(field);
|
||||||
|
|
||||||
Build(property, depth);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
readonly Foldout foldout;
|
readonly Foldout foldout;
|
||||||
readonly PropertyField field;
|
readonly PropertyField field;
|
||||||
|
readonly int depth;
|
||||||
bool isNull;
|
bool isNull;
|
||||||
|
|
||||||
public bool IsObjectNull => isNull;
|
public bool IsObjectNull => isNull;
|
||||||
@ -73,7 +64,23 @@ namespace Alchemy.Editor.Elements
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Build(SerializedProperty property, int depth)
|
void OnPropertyChanged(SerializedProperty property)
|
||||||
|
{
|
||||||
|
isNull = property.objectReferenceValue == null;
|
||||||
|
|
||||||
|
field.Q<Label>().text = isNull ? ObjectNames.NicifyVariableName(property.displayName) : string.Empty;
|
||||||
|
field.pickingMode = PickingMode.Ignore;
|
||||||
|
|
||||||
|
var objectField = field.Q<ObjectField>();
|
||||||
|
objectField.pickingMode = PickingMode.Ignore;
|
||||||
|
|
||||||
|
var label = objectField.Q<Label>();
|
||||||
|
label.pickingMode = PickingMode.Ignore;
|
||||||
|
|
||||||
|
Build(property);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Build(SerializedProperty property)
|
||||||
{
|
{
|
||||||
foldout.Clear();
|
foldout.Clear();
|
||||||
var toggle = foldout.Q<Toggle>();
|
var toggle = foldout.Q<Toggle>();
|
||||||
|
Loading…
Reference in New Issue
Block a user