Back to API Reference
Class

UniTextDropdown

Inherits:Selectable
Implements:IPointerClickHandlerISubmitHandlerICancelHandler

Single-selection dropdown with UniText captions and prefab-authored list, item, and outside-click templates.

Nested Types

public RectTransform Template{ get; set }

Gets or sets the inactive list template, containing a Canvas, CanvasGroup, raycaster, and item template.

public Button BlockerTemplate{ get; set }

Gets or sets the inactive outside-click button template, containing its own Canvas and raycaster.

public UniText CaptionText{ get; set }

Gets or sets the optional text displaying the selected caption.

public Image CaptionImage{ get; set }

Gets or sets the optional image displaying the selected sprite.

public Graphic Placeholder{ get; set }

Gets or sets the graphic shown without a selection; assigning one permits Value to be -1.

public float FadeDuration{ get; set }

Gets or sets the unscaled duration of opening and closing fades, in seconds; zero switches immediately.

public int Value{ get; set }

Gets or sets the selected index, clamped to the available options; -1 represents no selection when a placeholder is assigned or the list is empty.

public DropdownEvent OnValueChanged{ get }

Gets the event invoked once when selection changes through Value or user input.

public bool IsExpanded{ get }

Gets whether the list exists, including its closing fade.

protected override void Awake()
protected override void OnEnable()
protected override void OnDisable()
public void SetValueWithoutNotify()

Changes selection and refreshes its presentation without invoking OnValueChanged.

public void RefreshShownValue()

Refreshes the caption, optional image, placeholder, and current item selection.

public void AddOptions()

Appends options and refreshes the presentation.

public void AddOptions()

Appends text-only options and refreshes the presentation.

public void AddOptions()

Appends image-only options and refreshes the presentation.

public void ClearOptions()

Removes all options and clears the selected caption without a selection event.

public virtual void OnPointerClick()
public virtual void OnSubmit()
public virtual void OnCancel()
public void Show()

Opens the list when active, interactable, and nonempty; an already open list is unchanged.

public void Hide()

Closes the list with its configured fade and returns focus to the dropdown; a closed or closing list is unchanged.

protected virtual Button CreateBlocker()

Instantiates the configured blocker under the root canvas, immediately below the list's sorting order.

protected virtual void DestroyBlocker()

Disposes of an inactive blocker instance after its close listener is removed.

protected virtual GameObject CreateDropdownList()

Creates an inactive copy of the list template with its component references preserved.

protected virtual void DestroyDropdownList()

Disposes of the inactive list and its remaining children.

protected virtual UniTextDropdownItem CreateItem()

Creates an inactive item with the template's component references preserved.

protected virtual void DestroyItem()

Releases an unbound item; the default leaves its destruction to the enclosing list.