Class UnityUiDropdownComponent
Unity UI dropdown component that provides expandable list selection functionality with keyboard and mouse navigation.
Extends selector component to handle dropdown-specific behaviors including list expansion, option navigation, and selection confirmation.
Implements IUiCancellable and IUiSubmittable interfaces for comprehensive dropdown interaction management within the Unity UI system.
Inheritance
Implements
Inherited Members
Namespace: Serenity.Ui.Infrastructure.Components
Assembly: Serenity.UnityUi.Infrastructure.dll
Syntax
public class UnityUiDropdownComponent : UnityUiSelectorComponent, IUiInteractable, IUiComponent, IUiSelectable, IUiCancellable, IComponent, IFoundationSettings, IUiSubmittable
Constructors
UnityUiDropdownComponent()
Initializes a new Unity UI dropdown component with dropdown interaction type configuration.
Sets up the component for expandable list selection operations within the UI system.
Declaration
public UnityUiDropdownComponent()
Fields
_isHidingDropdown
Declaration
protected bool _isHidingDropdown
Field Value
| Type | Description |
|---|---|
| bool | Indicates whether the dropdown is currently being closed. |
_isOpeningDropdown
Declaration
protected bool _isOpeningDropdown
Field Value
| Type | Description |
|---|---|
| bool | Indicates whether the dropdown is currently being opened. |
Properties
CancellableActions
Gets or sets the cancellable actions interface for dropdown cancellation event handling.
Manages callbacks for dropdown dismissal and cancellation operations.
Declaration
public IUiCancellableActions CancellableActions { get; set; }
Property Value
| Type | Description |
|---|---|
| IUiCancellableActions | The cancellable actions interface |
Methods
Cancel()
Handles cancellation actions with dropdown state-aware behavior.
If dropdown is open, closes the dropdown without selection; otherwise invokes cancel actions for the component.
Provides context-sensitive cancellation functionality for dropdown interactions.
Declaration
public override void Cancel()
Overrides
DecrementValue()
Overrides decrement value to disable default selector behavior.
Dropdown components handle value changes through selection rather than direct decrement operations.
Empty implementation prevents unintended value modifications outside of dropdown selection flow.
Declaration
public override void DecrementValue()
Overrides
GetDropdownSelectables(CustomTMPDropdown)
Gets all selectable UI elements within the dropdown list excluding the dropdown itself.
Returns the list of toggles and other selectable elements that represent dropdown options.
Filters out the main dropdown component to focus on option selectables only.
Declaration
public List<Selectable> GetDropdownSelectables(CustomTMPDropdown dropdown)
Parameters
| Type | Name | Description |
|---|---|---|
| CustomTMPDropdown | dropdown | The dropdown component to scan for selectables |
Returns
| Type | Description |
|---|---|
| List<Selectable> | List of selectable elements representing dropdown options, or null if dropdown is invalid |
IncrementValue()
Overrides increment value to disable default selector behavior.
Dropdown components handle value changes through selection rather than direct increment operations.
Empty implementation prevents unintended value modifications outside of dropdown selection flow.
Declaration
public override void IncrementValue()
Overrides
IsShowingDropdown()
Checks whether the dropdown list is currently expanded and visible to the user.
Returns true if the dropdown is showing its option list, false if it's collapsed.
Declaration
public bool IsShowingDropdown()
Returns
| Type | Description |
|---|---|
| bool | True if dropdown is expanded, false if collapsed |
SelectDropdownOption()
Selects the dropdown option that matches the current caption text.
Finds and selects the option whose text matches the dropdown's displayed caption value.
Useful for synchronizing selection state with displayed content.
Declaration
public void SelectDropdownOption()
Exceptions
| Type | Condition |
|---|---|
| NullReferenceException | Thrown when dropdown component is not found |
| ArgumentOutOfRangeException | Thrown when matching option index is invalid |
SelectDropdownOption(int)
Programmatically selects a dropdown option by its index with validation.
Updates the dropdown's selection state and visual appearance to reflect the specified option.
Provides external interface for dropdown option selection with bounds checking.
Declaration
public void SelectDropdownOption(int index)
Parameters
| Type | Name | Description |
|---|---|---|
| int | index | The zero-based index of the option to select |
Exceptions
| Type | Condition |
|---|---|
| NullReferenceException | Thrown when dropdown component is not found |
| ArgumentOutOfRangeException | Thrown when index is outside valid range |
SelectNextComponent()
Overrides next component selection to handle dropdown navigation.
If dropdown is open, navigates to next option within the dropdown; otherwise performs normal component navigation.
Provides context-aware navigation behavior for dropdown interactions.
Declaration
public override void SelectNextComponent()
Overrides
SelectPreviousComponent()
Overrides previous component selection to handle dropdown navigation.
If dropdown is open, navigates to previous option within the dropdown; otherwise performs normal component navigation.
Provides context-aware navigation behavior for dropdown interactions.
Declaration
public override void SelectPreviousComponent()
Overrides
SetValue(int)
Sets the selected option by index and updates the dropdown display with validation.
Overrides base selector behavior to properly update the Unity dropdown component's visual state and option selection.
Validates the index is within the valid range of dropdown options before applying the change.
Declaration
public override void SetValue(int index)
Parameters
| Type | Name | Description |
|---|---|---|
| int | index | The zero-based index of the option to select |
Overrides
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | Thrown when index is outside the valid range of dropdown options |
Submit()
Handles submission actions with dropdown state-aware behavior.
If dropdown is closed, opens the dropdown list; if open, selects the currently highlighted option and closes the dropdown.
Provides dual-mode submission behavior for intuitive dropdown interaction.
Declaration
public override void Submit()
Overrides
Exceptions
| Type | Condition |
|---|---|
| NullReferenceException | Thrown when dropdown component is not found |
UpdateOption()
Updates the dropdown option selection to match the current selected value.
Synchronizes the Unity dropdown component's selected index with the internal selection state.
Declaration
public void UpdateOption()