Skip to content

Dropdown

Popup options selector with optional search filtering. Displays a scrollable list of options with auto-direction detection.

Inspector Setup

  1. Add AutoLayout Dropdown to a GameObject with AutoLayout.
  2. Populate the Options list in the Inspector.
  3. Configure appearance and behavior settings.
FieldTypeDefaultDescription
OptionsList<string>-List of option strings
Selected Indexint-1Currently selected option index
Popup Max Heightfloat400Maximum popup height in pixels
Item Heightfloat48Height of each option item
DirectionDropdownDirectionAutoPopup direction: Auto, Up, or Down
SearchableboolfalseShow search/filter field

Code Usage

AutoUI Builder

// Basic dropdown — set sizing on the parent before calling .Dropdown()
AutoUI.Create()
.Width(280).Height(40)
.Dropdown()
.Options(new[] { "Option A", "Option B", "Option C" })
.DefaultIndex(0)
.PopupMaxHeight(300)
.OnValueChanged(index => Debug.Log($"Selected: {index}"))
.Capture(dd => m_Dropdown = dd)
.End()
.Build();
// Searchable dropdown
AutoUI.Create()
.WidthFill().Height(48)
.Dropdown()
.Options(countriesList)
.DefaultIndex(0)
.PopupMaxHeight(400)
.Searchable()
.OnValueChanged(OnCountryChanged)
.Capture(dd => m_SearchDropdown = dd)
.End()
.Build();

Sizing note: .Dropdown() configures the parent as a Row with CrossAlign(Center) (the layout the dropdown header needs), but does not set Width/Height/Padding — those are your call. Set them on the parent before the .Dropdown() call.

Programmatic Control

// Update options at runtime
m_Dropdown.Options = new List<string> { "New A", "New B", "New C" };
// Change selection
m_Dropdown.SelectedIndex = 1;
// Read selection
string selected = m_Dropdown.SelectedText;
int index = m_Dropdown.SelectedIndex;
// Toggle popup
m_Dropdown.Toggle();
m_Dropdown.Show();
m_Dropdown.Hide();

Methods

MethodDescription
Toggle()Open or close the popup
Show()Open the popup
Hide()Close the popup

Properties

PropertyTypeDescription
SelectedIndexintGet/set selected option index
SelectedTextstringGet the selected option text
IsOpenboolWhether popup is visible
OptionsList<string>Get/set options list
PopupMaxHeightfloatMaximum popup height
ItemHeightfloatPer-item height
DirectionDropdownDirectionPopup direction
SearchableboolSearch field enabled

Events

EventSignatureDescription
OnValueChangedAction<int>Fires when selection changes

Callbacks

CallbackSignatureDescription
BindItemCallbackAction<GameObject, int, bool>Custom item rendering (go, index, isSelected)
UnbindItemCallbackAction<GameObject, int>Cleanup on item recycle

Builder API

MethodDescription
.Options(string[]) / .Options(List<string>)Set option strings
.DefaultIndex(int)Set initial selection
.PopupMaxHeight(float)Set max popup height
.ItemHeight(float)Set item height
.Direction(DropdownDirection)Set popup direction
.Searchable()Enable search field
.OnValueChanged(Action<int>)Subscribe to selection changes
.Capture(Action<AutoLayoutDropdown>)Capture component reference
.End()Return to parent LayoutBuilder

Notes

  • Direction = Auto measures available space above/below and picks the best direction.
  • The popup is created in an overlay layer so it renders above other UI.
  • Search filtering is case-insensitive substring matching.