Version 2.1.0.0

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)]
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
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

Properties

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; }
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.
public bool Expanded { get; set; }
ExpandedHasValue
Whether the Expanded property is set.
public bool ExpandedHasValue { get; }
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; }

This website is brand new and built with the Odin 2.1 beta in mind. This means you might discover some features such as attribute expressions that are only available in the beta.

You can download the 2.1 beta from here and read the patch-notes here.