diff --git a/Alchemy/Assets/Alchemy/Editor/Elements/PropertyListView.cs b/Alchemy/Assets/Alchemy/Editor/Elements/PropertyListView.cs index b72ec5e..361ab9d 100644 --- a/Alchemy/Assets/Alchemy/Editor/Elements/PropertyListView.cs +++ b/Alchemy/Assets/Alchemy/Editor/Elements/PropertyListView.cs @@ -16,33 +16,26 @@ public PropertyListView(SerializedProperty property, int depth) { Assert.IsTrue(property.isArray); - var settings = property.GetAttribute(true); + var parentObj = property.GetDeclaredObject(); + var events = property.GetAttribute(true); - var listView = new ListView + var listView = GUIHelper.CreateListViewFromFieldInfo(parentObj, property.GetFieldInfo()); + listView.headerTitle = ObjectNames.NicifyVariableName(property.displayName); + listView.bindItem = (element, index) => { - reorderable = settings == null ? true : settings.Reorderable, - reorderMode = settings == null ? ListViewReorderMode.Animated : settings.ReorderMode, - showBorder = settings == null ? true : settings.ShowBorder, - showFoldoutHeader = settings == null ? true : settings.ShowFoldoutHeader, - showBoundCollectionSize = settings == null ? true : (settings.ShowFoldoutHeader && settings.ShowBoundCollectionSize), - selectionType = settings == null ? SelectionType.Multiple : settings.SelectionType, - headerTitle = ObjectNames.NicifyVariableName(property.displayName), - showAddRemoveFooter = settings == null ? true : settings.ShowAddRemoveFooter, - fixedItemHeight = 20f, - virtualizationMethod = CollectionVirtualizationMethod.DynamicHeight, - showAlternatingRowBackgrounds = settings == null ? AlternatingRowBackground.None : settings.ShowAlternatingRowBackgrounds, - bindItem = (element, index) => + var arrayElement = property.GetArrayElementAtIndex(index); + var e = new AlchemyPropertyField(arrayElement, property.GetPropertyType(true), depth + 1, true); + element.Add(e); + element.Bind(arrayElement.serializedObject); + e.TrackPropertyValue(arrayElement, x => { - var arrayElement = property.GetArrayElementAtIndex(index); - var e = new AlchemyPropertyField(arrayElement, property.GetPropertyType(true), depth + 1, true); - element.Add(e); - element.Bind(arrayElement.serializedObject); - }, - unbindItem = (element, index) => - { - element.Clear(); - element.Unbind(); - } + ReflectionHelper.Invoke(parentObj, events.OnItemChanged, new object[] { index, x.GetValue() }); + }); + }; + listView.unbindItem = (element, index) => + { + element.Clear(); + element.Unbind(); }; var label = listView.Q