From 0d1063b13a39f421c3b0e39f31c1d1e5dbf3b230 Mon Sep 17 00:00:00 2001 From: AnnulusGames Date: Wed, 21 Feb 2024 09:58:39 +0900 Subject: [PATCH 1/5] Change: add CreateListViewFromSettingsAttribute --- .../Editor/Elements/PropertyListView.cs | 36 +++++++------------ .../Alchemy/Editor/Internal/GUIHelper.cs | 17 +++++++++ 2 files changed, 29 insertions(+), 24 deletions(-) diff --git a/Alchemy/Assets/Alchemy/Editor/Elements/PropertyListView.cs b/Alchemy/Assets/Alchemy/Editor/Elements/PropertyListView.cs index b72ec5e..0f8ce0a 100644 --- a/Alchemy/Assets/Alchemy/Editor/Elements/PropertyListView.cs +++ b/Alchemy/Assets/Alchemy/Editor/Elements/PropertyListView.cs @@ -18,31 +18,19 @@ public PropertyListView(SerializedProperty property, int depth) var settings = property.GetAttribute(true); - var listView = new ListView + var listView = GUIHelper.CreateListViewFromSettingsAttribute(settings); + 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); - }, - unbindItem = (element, index) => - { - element.Clear(); - element.Unbind(); - } + var arrayElement = property.GetArrayElementAtIndex(index); + var e = new AlchemyPropertyField(arrayElement, property.GetPropertyType(true), depth + 1, true); + element.Add(e); + element.Bind(arrayElement.serializedObject); + }; + listView.unbindItem = (element, index) => + { + element.Clear(); + element.Unbind(); }; var label = listView.Q