ListDrawerSettingsAttribute

Customize the behavior for lists and arrays in the inspector.

namespace Sirenix.OdinInspector
{
[AttributeUsageAttribute((AttributeTargets)384, AllowMultiple = False, Inherited = True)]
public sealed class ListDrawerSettingsAttribute : Attribute
}

Requirements

Namespace: Sirenix.OdinInspector
Assembly: Sirenix.OdinInspector
Version: 1.0.6.1

Properties

Return Type Definition Description
bool AlwaysAddDefaultValue If true, object/type pickers will never be shown when the list add button is clicked, and default(T) will always be added instantly instead, where T is the element type of the list.
string CustomAddFunction Override the default behaviour for adding objects to the list. If the referenced member returns the list type element, it will be called once per selected object. If the referenced method returns void, it will only be called once regardless of how many objects are selected.
bool DraggableHasValue Whether the Draggable property is set.
bool DraggableItems Override the default setting specified in the Advanced Odin Preferences window and explicitly tell whether items should be draggable or not.
bool Expanded Override the default setting specified in the Advanced Odin Preferences window and explicitly tell whether or not the list should be expanded or collapsed by default.
bool ExpandedHasValue Whether the Expanded property is set.
bool HideAddButton If true, the add button will not be rendered in the title toolbar. You can use OnTitleBarGUI to implement your own add button.
bool IsReadOnly Mark a list as read-only. This removes all editing capabilities from the list such as Add, Drag and delete, but without disabling GUI for each element drawn as otherwise would be the case if the ReadOnlyAttribute was used.
bool IsReadOnlyHasValue Whether the IsReadOnly property is set.
string ListElementLabelName Specify the name of a member inside each list element which defines the label being drawn for each list element.
int NumberOfItemsPerPage Override the default setting specified in the Advanced Odin Preferences window and explicitly tells how many items each page should contain.
bool NumberOfItemsPerPageHasValue Whether the NumberOfItemsPerPage property is set.
string OnBeginListElementGUI Calls a method before each list element. The member referenced must have a return type of void, and an index parameter of type int which repricents the element index being drawn.
string OnEndListElementGUI Calls a method after each list element. The member referenced must have a return type of void, and an index parameter of type int which repricents the element index being drawn.
string OnTitleBarGUI Use this to inject custom GUI into the title-bar of the list.
bool PagingHasValue Whether the Paging property is set.
bool ShowIndexLabels If true, a label is drawn for each element which shows the index of the element.
bool ShowIndexLabelsHasValue Whether the ShowIndexLabels property is set.
bool ShowItemCount Override the default setting specified in the Advanced Odin Preferences window and explicitly tell whether or not item count should be shown.
bool ShowItemCountHasValue Whether the ShowItemCount property is set.
bool ShowPaging Override the default setting specified in the Advanced Odin Preferences window and explicitly tell whether paging should be enabled or not.

Example

This example shows how you can add your own custom add button to a list.

[ListDrawerSettings(ShowAddButton = false, OnTitleBarGUI = "DrawTitleBarGUI")]
public List<MyType> SomeList;

#if UNITY_EDITOR
private void DrawTitleBarGUI()
{
    if (SirenixEditorGUI.ToolbarButton(EditorIcons.Plus))
    {
        this.SomeList.Add(new MyType());
    }
}
#end if