Logo
UI Elements

Dropdown

Single or multiple selection with filtering and recycled items

Overview

Dropdown displays a list of choices from a compact header. Dropdown Multi Select uses the same item model for multiple choices, and both support filtering and recycled views for large lists.

Preview

Usage

Create a Dropdown prefab and populate Items.

Set its starting selection and maximum open height.

Bind On Item Selected to receive the selected index.

Enable virtualization on the linked Scroll Rect for long lists.


Customization

Filtering and Multiple Selection

Use the Dropdown - Input prefab for a searchable list, or Dropdown - Multi Select when several choices can be selected at once. Dropdown Input connects an input field from any text provider to the list's filter.

Presets and Item Prefabs

Dropdown uses a complete dropdown prefab plus an Item Prefab for its rows. The supplied versions are in Evo UI/Prefabs/Selection.

Duplicate the dropdown prefab and its item prefab into your own project folder, or create prefab variants.

Edit the row's background, label, icon, and styling in Prefab Mode. Keep the Evo UI Button component on the row root and its content references assigned. For multiple selection, keep Dropdown Multi Select Item and its checkmark reference too.

On your dropdown prefab, open References and assign the new Item Prefab. Keep Header Button, Scroll Rect, and Item Parent connected to the corresponding objects in the hierarchy.

Adjust the header and list panel, then use your dropdown prefab in the scene. Match Item Height to the row design, especially with virtualization.

Changing the item prefab affects every row generated from it. Keep the row's label and icon objects enabled in the prefab if your items use them.

Appearance and Animation

Use item height, spacing, padding, and scrollbar placement to shape the list. Edit Open Animation and Close Animation as Evo Tween sequences.


Performance

For long lists, enable virtualization on the linked Scroll Rect. It reuses a small set of row objects as you scroll. Keep application data in items and avoid retaining generated view references.


Public API

Use Dropdown in the Evo.UI namespace.

Selection indices refer to the source item list, even when filtering hides some entries. Pass an empty string to SetFilter() to show the full list again.

Properties

NameTypeDescription
SelectedIndexintCurrent selection index.
SelectedItemItemRead-only selected item.
IsOpenboolWhether the dropdown is open.
IsVirtualizedboolWhether the list uses virtualization.
VisibleItemCountintNumber of entries matching the filter.

Fields

NameTypeDescription
itemsList<Item>Source list of Dropdown.Item entries.
itemPrefabGameObjectRow prefab with an Evo UI Button on its root.
headerButtonButtonHeader showing the selection and opening the list.
scrollRectScrollRectEvo UI Scroll Rect containing the list.
itemParentTransformParent for generated rows.

Methods

NameParametersDescription
Open()NoneOpens the list.
Close()NoneCloses the list.
Toggle()NoneToggles the open state.
SelectItem()int index, bool invokeEventsSelects an item by index.
SelectItem()int indexSelects an item by index.
SelectItem()string labelSelects an item by label; returns whether it was found. Returns bool.
SelectItem()string label, bool invokeEventsSelects an item by label; returns whether it was found. Returns bool.
SelectItem()Item item, bool invokeEvents = trueSelects an item by reference.
ClearSelection()NoneClears the selection.
AddItem()Item item, bool generate = trueAdds an Item entry.
AddItem()string label, Sprite icon = null, bool generate = trueAdds an entry from its label and optional icon.
AddItems()params Item[] newItemsAdds multiple Item entries.
AddItems()params string[] labelsAdds entries from their labels.
RemoveItem()int indexRemoves an entry by index.
RemoveItem()string labelRemoves an entry by label and reports success. Returns bool.
ClearAllItems()NoneRemoves every item.
RefreshItems()NoneRebuilds item bindings after direct list changes.
SetFilter()string valueFilters visible items by text.

Events

NameTypeDescription
onItemSelectedUnityEvent<int>Invoked with the selected source index.
onOpenUnityEventList opened.
onCloseUnityEventList closed.

Use SelectedCount, SelectedIndices, and SelectedItems to read the selection. The returned index list is a copy. onItemToggled is a UnityEvent<int, bool> with the index and selected state; onSelectionChanged is a UnityEvent<List<int>> containing the selected indices.

NameParametersDescription
ToggleItem()int index, bool triggerEvents = trueToggles one item.
DeselectItem()int index, bool triggerEvents = trueDeselects one item.
SelectAll()bool triggerEvents = trueSelects every item.
DeselectAll()bool triggerEvents = trueClears the selection.

Example

DropdownExample.cs
using UnityEngine;
using Evo.UI;

public class DropdownExample : MonoBehaviour
{
    [SerializeField] private Dropdown target;

    private void Start()
    {
        target.ClearAllItems();
        target.AddItems("Low", "Medium", "High");
        // Restore the initial choice without firing selection callbacks.
        target.SelectItem(1, invokeEvents: false);
        target.onItemSelected.AddListener(OnQualitySelected);
    }

    private void OnQualitySelected(int index)
    {
        Debug.Log($"Quality: {target.items[index].label} (index {index})");
    }

    // Connect an input field's value-changed event to this method.
    public void FilterChoices(string text)
    {
        target.SetFilter(text);
    }

    private void OnDestroy()
    {
        if (target != null)
            target.onItemSelected.RemoveListener(OnQualitySelected);
    }
}

On this page