Class CustomTMPDropdown
Custom TextMeshPro dropdown component that extends TMP_Dropdown with hover selection functionality.
Automatically selects dropdown items when the mouse pointer enters them and provides events for dropdown visibility changes.
Enhances the standard Unity dropdown with improved user interaction and event notification capabilities.
Namespace: Serenity.Ui.Infrastructure.Components
Assembly: Serenity.UnityUi.Infrastructure.dll
Syntax
public class CustomTMPDropdown : TMP_Dropdown
Constructors
CustomTMPDropdown()
Declaration
public CustomTMPDropdown()
Fields
OnDropdownShown
Declaration
public CustomTMPDropdown.DropdownShownEvent OnDropdownShown
Field Value
| Type | Description |
|---|---|
| CustomTMPDropdown.DropdownShownEvent | Event that is triggered when the dropdown list becomes visible. |
Methods
CreateDropdownList(GameObject)
Creates the dropdown list GameObject and adds hover selection functionality to all toggle items.
Overrides the base implementation to add EventTrigger components that respond to pointer enter events.
Each dropdown item will be automatically selected when the mouse cursor hovers over it, improving user experience and accessibility.
Additionally manages localization component state based on the isTranslatingValue setting.
Declaration
protected override GameObject CreateDropdownList(GameObject template)
Parameters
| Type | Name | Description |
|---|---|---|
| GameObject | template | The template GameObject used to create the dropdown list structure |
Returns
| Type | Description |
|---|---|
| GameObject | The created dropdown list GameObject with enhanced hover functionality |
SelectDropdown(int)
Programmatically selects a dropdown item by its index and updates the displayed value.
This method is called automatically when the user hovers over dropdown items, but can also be called manually to select items programmatically.
Updates both the selected value and refreshes the visual display to reflect the new selection.
Declaration
public void SelectDropdown(int index)
Parameters
| Type | Name | Description |
|---|---|---|
| int | index | The zero-based index of the dropdown item to select |
SetIsTranslatingValue(bool)
Sets whether dropdown item values should be translated using the localization system.
When set to false, disables UnityUiTMP_TextLocalizationUpdaterComponent on dropdown items to prevent unnecessary localization.
Must be called before the dropdown is opened to affect item instantiation.
Declaration
public void SetIsTranslatingValue(bool isTranslating)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | isTranslating | True to enable translation, false to disable |