mirror of
https://github.com/AnnulusGames/Alchemy.git
synced 2025-01-22 08:18:51 -05:00
Change: add CreateListViewFromSettingsAttribute
This commit is contained in:
parent
d874e72f18
commit
0d1063b13a
@ -18,31 +18,19 @@ namespace Alchemy.Editor.Elements
|
|||||||
|
|
||||||
var settings = property.GetAttribute<ListViewSettingsAttribute>(true);
|
var settings = property.GetAttribute<ListViewSettingsAttribute>(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,
|
var arrayElement = property.GetArrayElementAtIndex(index);
|
||||||
reorderMode = settings == null ? ListViewReorderMode.Animated : settings.ReorderMode,
|
var e = new AlchemyPropertyField(arrayElement, property.GetPropertyType(true), depth + 1, true);
|
||||||
showBorder = settings == null ? true : settings.ShowBorder,
|
element.Add(e);
|
||||||
showFoldoutHeader = settings == null ? true : settings.ShowFoldoutHeader,
|
element.Bind(arrayElement.serializedObject);
|
||||||
showBoundCollectionSize = settings == null ? true : (settings.ShowFoldoutHeader && settings.ShowBoundCollectionSize),
|
};
|
||||||
selectionType = settings == null ? SelectionType.Multiple : settings.SelectionType,
|
listView.unbindItem = (element, index) =>
|
||||||
headerTitle = ObjectNames.NicifyVariableName(property.displayName),
|
{
|
||||||
showAddRemoveFooter = settings == null ? true : settings.ShowAddRemoveFooter,
|
element.Clear();
|
||||||
fixedItemHeight = 20f,
|
element.Unbind();
|
||||||
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 label = listView.Q<Label>();
|
var label = listView.Q<Label>();
|
||||||
|
@ -51,6 +51,23 @@ namespace Alchemy.Editor
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static ListView CreateListViewFromSettingsAttribute(ListViewSettingsAttribute settings)
|
||||||
|
{
|
||||||
|
return new ListView
|
||||||
|
{
|
||||||
|
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,
|
||||||
|
showAddRemoveFooter = settings == null ? true : settings.ShowAddRemoveFooter,
|
||||||
|
fixedItemHeight = 20f,
|
||||||
|
virtualizationMethod = CollectionVirtualizationMethod.DynamicHeight,
|
||||||
|
showAlternatingRowBackgrounds = settings == null ? AlternatingRowBackground.None : settings.ShowAlternatingRowBackgrounds,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
public static PropertyField CreateObjectPropertyField(SerializedProperty property, Type type)
|
public static PropertyField CreateObjectPropertyField(SerializedProperty property, Type type)
|
||||||
{
|
{
|
||||||
Assert.IsTrue(property.propertyType == SerializedPropertyType.ObjectReference);
|
Assert.IsTrue(property.propertyType == SerializedPropertyType.ObjectReference);
|
||||||
|
Loading…
Reference in New Issue
Block a user