Version 3.3.1.2

Odin has a dedicated attribute overview with examples

ListDrawerSettingsAttribute class

Namespace: Sirenix.OdinInspector
Assembly: Sirenix.OdinInspector.Attributes
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Interface | AttributeTargets.Parameter | AttributeTargets.Delegate | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter | AttributeTargets.All, AllowMultiple = true, Inherited = true)]
[Conditional("UNITY_EDITOR")]
[DontApplyToListElements]
public sealed class ListDrawerSettingsAttribute : Attribute, _Attribute
Customize the behavior for lists and arrays in the inspector.
Inheritance
  • System.Object
  • System.Attribute
  • ListDrawerSettingsAttribute
Remarks

This attribute is scheduled for refactoring.

Example

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

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

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

Constructors

ListDrawerSettingsAttribute()
public ListDrawerSettingsAttribute()

Fields

AddCopiesLastElement
Whether adding a new element should copy the last element. False by default.
public bool AddCopiesLastElement
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.
public bool AlwaysAddDefaultValue
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.
public string CustomAddFunction
CustomRemoveElementFunction
public string CustomRemoveElementFunction
CustomRemoveIndexFunction
public string CustomRemoveIndexFunction
ElementColor
A resolved string with "int index" and "Color defaultColor" parameters that lets you control the color of individual elements. Supports a variety of color formats, including named colors (e.g. "red", "orange", "green", "blue"), hex codes (e.g. "#FF0000" and "#FF0000FF"), and RGBA (e.g. "RGBA(1,1,1,1)") or RGB (e.g. "RGB(1,1,1)"), including Odin attribute expressions (e.g "@this.MyColor"). Here are the available named colors: black, blue, clear, cyan, gray, green, grey, magenta, orange, purple, red, transparent, transparentBlack, transparentWhite, white, yellow, lightblue, lightcyan, lightgray, lightgreen, lightgrey, lightmagenta, lightorange, lightpurple, lightred, lightyellow, darkblue, darkcyan, darkgray, darkgreen, darkgrey, darkmagenta, darkorange, darkpurple, darkred, darkyellow.
public string ElementColor
HideAddButton
If true, the add button will not be rendered in the title toolbar. You can use OnTitleBarGUI to implement your own add button.
public bool HideAddButton
HideRemoveButton
If true, the remove button will not be rendered on list items. You can use OnBeginListElementGUI and OnEndListElementGUI to implement your own remove button.
public bool HideRemoveButton
ListElementLabelName
Specify the name of a member inside each list element which defines the label being drawn for each list element.
public string ListElementLabelName
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 represents the element index being drawn.
public string OnBeginListElementGUI
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 represents the element index being drawn.
public string OnEndListElementGUI
ShowFoldout
Whether to show a foldout for the collection or not. If this is set to false, the collection will *always* be expanded.
public bool ShowFoldout

Properties

DefaultExpandedState
Override the default setting specified in the Odin Preferences window and explicitly tell whether or not the list should be expanded or collapsed by default. Note that this will override the persisted expand state, as this is set *every time* the collection drawer is initialized.
public bool DefaultExpandedState { get; set; }
DefaultExpandedStateHasValue
Whether the DefaultExpandedState property is set.
public bool DefaultExpandedStateHasValue { get; }
DraggableHasValue
Whether the Draggable property is set.
public bool DraggableHasValue { get; }
DraggableItems
Override the default setting specified in the Advanced Odin Preferences window and explicitly tell whether items should be draggable or not.
public bool DraggableItems { get; set; }
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.
public bool IsReadOnly { get; set; }
IsReadOnlyHasValue
Whether the IsReadOnly property is set.
public bool IsReadOnlyHasValue { get; }
NumberOfItemsPerPage
Override the default setting specified in the Advanced Odin Preferences window and explicitly tells how many items each page should contain.
public int NumberOfItemsPerPage { get; set; }
NumberOfItemsPerPageHasValue
Whether the NumberOfItemsPerPage property is set.
public bool NumberOfItemsPerPageHasValue { get; }
OnTitleBarGUI
Use this to inject custom GUI into the title-bar of the list.
public string OnTitleBarGUI { get; set; }
PagingHasValue
Whether the Paging property is set.
public bool PagingHasValue { get; }
ShowIndexLabels
If true, a label is drawn for each element which shows the index of the element.
public bool ShowIndexLabels { get; set; }
ShowIndexLabelsHasValue
Whether the ShowIndexLabels property is set.
public bool ShowIndexLabelsHasValue { get; }
ShowItemCount
Override the default setting specified in the Advanced Odin Preferences window and explicitly tell whether or not item count should be shown.
public bool ShowItemCount { get; set; }
ShowItemCountHasValue
Whether the ShowItemCount property is set.
public bool ShowItemCountHasValue { get; }
ShowPaging
Override the default setting specified in the Advanced Odin Preferences window and explicitly tell whether paging should be enabled or not.
public bool ShowPaging { get; set; }