docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class TMP_Dropdown

    Inheritance
    object
    Object
    Component
    Behaviour
    MonoBehaviour
    UIBehaviour
    Selectable
    TMP_Dropdown
    Implements
    IMoveHandler
    IPointerDownHandler
    IPointerUpHandler
    IPointerEnterHandler
    IPointerExitHandler
    ISelectHandler
    IDeselectHandler
    IPointerClickHandler
    ISubmitHandler
    ICancelHandler
    IEventSystemHandler
    Inherited Members
    Selectable.s_Selectables
    Selectable.s_SelectableCount
    Selectable.allSelectablesArray
    Selectable.allSelectableCount
    Selectable.allSelectables
    Selectable.AllSelectablesNoAlloc(Selectable[])
    Selectable.m_CurrentIndex
    Selectable.navigation
    Selectable.transition
    Selectable.colors
    Selectable.spriteState
    Selectable.animationTriggers
    Selectable.targetGraphic
    Selectable.interactable
    Selectable.image
    Selectable.animator
    Selectable.OnCanvasGroupChanged()
    Selectable.IsInteractable()
    Selectable.OnDidApplyAnimationProperties()
    Selectable.OnEnable()
    Selectable.OnTransformParentChanged()
    Selectable.Reset()
    Selectable.currentSelectionState
    Selectable.InstantClearState()
    Selectable.DoStateTransition(Selectable.SelectionState, bool)
    Selectable.FindSelectable(Vector3)
    Selectable.FindSelectableOnLeft()
    Selectable.FindSelectableOnRight()
    Selectable.FindSelectableOnUp()
    Selectable.FindSelectableOnDown()
    Selectable.OnMove(AxisEventData)
    Selectable.IsHighlighted()
    Selectable.IsPressed()
    Selectable.OnPointerDown(PointerEventData)
    Selectable.OnPointerUp(PointerEventData)
    Selectable.OnPointerEnter(PointerEventData)
    Selectable.OnPointerExit(PointerEventData)
    Selectable.OnSelect(BaseEventData)
    Selectable.OnDeselect(BaseEventData)
    Selectable.Select()
    UIBehaviour.OnDestroy()
    UIBehaviour.IsActive()
    UIBehaviour.OnRectTransformDimensionsChange()
    UIBehaviour.OnBeforeTransformParentChanged()
    UIBehaviour.OnCanvasHierarchyChanged()
    UIBehaviour.IsDestroyed()
    MonoBehaviour.IsInvoking()
    MonoBehaviour.CancelInvoke()
    MonoBehaviour.Invoke(string, float)
    MonoBehaviour.InvokeRepeating(string, float, float)
    MonoBehaviour.CancelInvoke(string)
    MonoBehaviour.IsInvoking(string)
    MonoBehaviour.StartCoroutine(string)
    MonoBehaviour.StartCoroutine(string, object)
    MonoBehaviour.StartCoroutine(IEnumerator)
    MonoBehaviour.StartCoroutine_Auto(IEnumerator)
    MonoBehaviour.StopCoroutine(IEnumerator)
    MonoBehaviour.StopCoroutine(Coroutine)
    MonoBehaviour.StopCoroutine(string)
    MonoBehaviour.StopAllCoroutines()
    MonoBehaviour.print(object)
    MonoBehaviour.destroyCancellationToken
    MonoBehaviour.useGUILayout
    MonoBehaviour.didStart
    MonoBehaviour.didAwake
    MonoBehaviour.runInEditMode
    Behaviour.enabled
    Behaviour.isActiveAndEnabled
    Component.GetComponent(Type)
    Component.GetComponent<T>()
    Component.TryGetComponent(Type, out Component)
    Component.TryGetComponent<T>(out T)
    Component.GetComponent(string)
    Component.GetComponentInChildren(Type, bool)
    Component.GetComponentInChildren(Type)
    Component.GetComponentInChildren<T>(bool)
    Component.GetComponentInChildren<T>()
    Component.GetComponentsInChildren(Type, bool)
    Component.GetComponentsInChildren(Type)
    Component.GetComponentsInChildren<T>(bool)
    Component.GetComponentsInChildren<T>(bool, List<T>)
    Component.GetComponentsInChildren<T>()
    Component.GetComponentsInChildren<T>(List<T>)
    Component.GetComponentInParent(Type, bool)
    Component.GetComponentInParent(Type)
    Component.GetComponentInParent<T>(bool)
    Component.GetComponentInParent<T>()
    Component.GetComponentsInParent(Type, bool)
    Component.GetComponentsInParent(Type)
    Component.GetComponentsInParent<T>(bool)
    Component.GetComponentsInParent<T>(bool, List<T>)
    Component.GetComponentsInParent<T>()
    Component.GetComponents(Type)
    Component.GetComponents(Type, List<Component>)
    Component.GetComponents<T>(List<T>)
    Component.GetComponents<T>()
    Component.GetComponentIndex()
    Component.CompareTag(string)
    Component.CompareTag(TagHandle)
    Component.SendMessageUpwards(string, object, SendMessageOptions)
    Component.SendMessageUpwards(string, object)
    Component.SendMessageUpwards(string)
    Component.SendMessageUpwards(string, SendMessageOptions)
    Component.SendMessage(string, object)
    Component.SendMessage(string)
    Component.SendMessage(string, object, SendMessageOptions)
    Component.SendMessage(string, SendMessageOptions)
    Component.BroadcastMessage(string, object, SendMessageOptions)
    Component.BroadcastMessage(string, object)
    Component.BroadcastMessage(string)
    Component.BroadcastMessage(string, SendMessageOptions)
    Component.transform
    Component.gameObject
    Component.tag
    Object.GetInstanceID()
    Object.GetHashCode()
    Object.Equals(object)
    Object.InstantiateAsync<T>(T)
    Object.InstantiateAsync<T>(T, Transform)
    Object.InstantiateAsync<T>(T, Vector3, Quaternion)
    Object.InstantiateAsync<T>(T, Transform, Vector3, Quaternion)
    Object.InstantiateAsync<T>(T, int)
    Object.InstantiateAsync<T>(T, int, Transform)
    Object.InstantiateAsync<T>(T, int, Vector3, Quaternion)
    Object.InstantiateAsync<T>(T, int, ReadOnlySpan<Vector3>, ReadOnlySpan<Quaternion>)
    Object.InstantiateAsync<T>(T, int, Transform, Vector3, Quaternion)
    Object.InstantiateAsync<T>(T, int, Transform, Vector3, Quaternion, CancellationToken)
    Object.InstantiateAsync<T>(T, int, Transform, ReadOnlySpan<Vector3>, ReadOnlySpan<Quaternion>)
    Object.InstantiateAsync<T>(T, int, Transform, ReadOnlySpan<Vector3>, ReadOnlySpan<Quaternion>, CancellationToken)
    Object.Instantiate(Object, Vector3, Quaternion)
    Object.Instantiate(Object, Vector3, Quaternion, Transform)
    Object.Instantiate(Object)
    Object.Instantiate(Object, Scene)
    Object.Instantiate(Object, Transform)
    Object.Instantiate(Object, Transform, bool)
    Object.Instantiate<T>(T)
    Object.Instantiate<T>(T, Vector3, Quaternion)
    Object.Instantiate<T>(T, Vector3, Quaternion, Transform)
    Object.Instantiate<T>(T, Transform)
    Object.Instantiate<T>(T, Transform, bool)
    Object.Destroy(Object, float)
    Object.Destroy(Object)
    Object.DestroyImmediate(Object, bool)
    Object.DestroyImmediate(Object)
    Object.FindObjectsOfType(Type)
    Object.FindObjectsOfType(Type, bool)
    Object.FindObjectsByType(Type, FindObjectsSortMode)
    Object.FindObjectsByType(Type, FindObjectsInactive, FindObjectsSortMode)
    Object.DontDestroyOnLoad(Object)
    Object.DestroyObject(Object, float)
    Object.DestroyObject(Object)
    Object.FindSceneObjectsOfType(Type)
    Object.FindObjectsOfTypeIncludingAssets(Type)
    Object.FindObjectsOfType<T>()
    Object.FindObjectsByType<T>(FindObjectsSortMode)
    Object.FindObjectsOfType<T>(bool)
    Object.FindObjectsByType<T>(FindObjectsInactive, FindObjectsSortMode)
    Object.FindObjectOfType<T>()
    Object.FindObjectOfType<T>(bool)
    Object.FindFirstObjectByType<T>()
    Object.FindAnyObjectByType<T>()
    Object.FindFirstObjectByType<T>(FindObjectsInactive)
    Object.FindAnyObjectByType<T>(FindObjectsInactive)
    Object.FindObjectsOfTypeAll(Type)
    Object.FindObjectOfType(Type)
    Object.FindFirstObjectByType(Type)
    Object.FindAnyObjectByType(Type)
    Object.FindObjectOfType(Type, bool)
    Object.FindFirstObjectByType(Type, FindObjectsInactive)
    Object.FindAnyObjectByType(Type, FindObjectsInactive)
    Object.ToString()
    Object.name
    Object.hideFlags
    object.Equals(object, object)
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    Namespace: TMPro
    Assembly: Unity.TextMeshPro.dll
    Syntax
    [AddComponentMenu("UI/Dropdown - TextMeshPro", 35)]
    [RequireComponent(typeof(RectTransform))]
    public class TMP_Dropdown : Selectable, IMoveHandler, IPointerDownHandler, IPointerUpHandler, IPointerEnterHandler, IPointerExitHandler, ISelectHandler, IDeselectHandler, IPointerClickHandler, ISubmitHandler, ICancelHandler, IEventSystemHandler

    Constructors

    TMP_Dropdown()

    Declaration
    protected TMP_Dropdown()

    Properties

    IsExpanded

    Declaration
    public bool IsExpanded { get; }
    Property Value
    Type Description
    bool

    MultiSelect

    Declaration
    public bool MultiSelect { get; set; }
    Property Value
    Type Description
    bool

    alphaFadeSpeed

    The time interval at which a drop down will appear and disappear

    Declaration
    public float alphaFadeSpeed { get; set; }
    Property Value
    Type Description
    float

    captionImage

    The Image component to hold the image of the currently selected option.

    Declaration
    public Image captionImage { get; set; }
    Property Value
    Type Description
    Image

    captionText

    The Text component to hold the text of the currently selected option.

    Declaration
    public TMP_Text captionText { get; set; }
    Property Value
    Type Description
    TMP_Text

    itemImage

    The Image component to hold the image of the item

    Declaration
    public Image itemImage { get; set; }
    Property Value
    Type Description
    Image

    itemText

    The Text component to hold the text of the item.

    Declaration
    public TMP_Text itemText { get; set; }
    Property Value
    Type Description
    TMP_Text

    onValueChanged

    Declaration
    public TMP_Dropdown.DropdownEvent onValueChanged { get; set; }
    Property Value
    Type Description
    TMP_Dropdown.DropdownEvent

    options

    Declaration
    public List<TMP_Dropdown.OptionData> options { get; set; }
    Property Value
    Type Description
    List<TMP_Dropdown.OptionData>

    placeholder

    The placeholder Graphic component. Shown when no option is selected.

    Declaration
    public Graphic placeholder { get; set; }
    Property Value
    Type Description
    Graphic

    template

    The Rect Transform of the template for the dropdown list.

    Declaration
    public RectTransform template { get; set; }
    Property Value
    Type Description
    RectTransform

    value

    Declaration
    public int value { get; set; }
    Property Value
    Type Description
    int

    Methods

    AddOptions(List<string>)

    Declaration
    public void AddOptions(List<string> options)
    Parameters
    Type Name Description
    List<string> options

    AddOptions(List<OptionData>)

    Declaration
    public void AddOptions(List<TMP_Dropdown.OptionData> options)
    Parameters
    Type Name Description
    List<TMP_Dropdown.OptionData> options

    AddOptions(List<Sprite>)

    Declaration
    public void AddOptions(List<Sprite> options)
    Parameters
    Type Name Description
    List<Sprite> options

    Awake()

    Declaration
    protected override void Awake()
    Overrides
    Selectable.Awake()

    ClearOptions()

    Clear the list of options in the Dropdown.

    Declaration
    public void ClearOptions()

    CreateBlocker(Canvas)

    Create a blocker that blocks clicks to other controls while the dropdown list is open.

    Declaration
    protected virtual GameObject CreateBlocker(Canvas rootCanvas)
    Parameters
    Type Name Description
    Canvas rootCanvas

    The root canvas the dropdown is under.

    Returns
    Type Description
    GameObject

    The created blocker object

    Remarks

    Override this method to implement a different way to obtain a blocker GameObject.

    CreateDropdownList(GameObject)

    Create the dropdown list to be shown when the dropdown is clicked. The dropdown list should correspond to the provided template GameObject, equivalent to instantiating a copy of it.

    Declaration
    protected virtual GameObject CreateDropdownList(GameObject template)
    Parameters
    Type Name Description
    GameObject template

    The template to create the dropdown list from.

    Returns
    Type Description
    GameObject

    The created drop down list gameobject.

    Remarks

    Override this method to implement a different way to obtain a dropdown list GameObject.

    CreateItem(DropdownItem)

    Create a dropdown item based upon the item template.

    Declaration
    protected virtual TMP_Dropdown.DropdownItem CreateItem(TMP_Dropdown.DropdownItem itemTemplate)
    Parameters
    Type Name Description
    TMP_Dropdown.DropdownItem itemTemplate

    e template to create the option item from.

    Returns
    Type Description
    TMP_Dropdown.DropdownItem

    The created dropdown item component

    Remarks

    Override this method to implement a different way to obtain an option item. The option item should correspond to the provided template DropdownItem and its GameObject, equivalent to instantiating a copy of it.

    DestroyBlocker(GameObject)

    Convenience method to explicitly destroy the previously generated blocker object

    Declaration
    protected virtual void DestroyBlocker(GameObject blocker)
    Parameters
    Type Name Description
    GameObject blocker

    The blocker object to destroy.

    Remarks

    Override this method to implement a different way to dispose of a blocker GameObject that blocks clicks to other controls while the dropdown list is open.

    DestroyDropdownList(GameObject)

    Convenience method to explicitly destroy the previously generated dropdown list

    Declaration
    protected virtual void DestroyDropdownList(GameObject dropdownList)
    Parameters
    Type Name Description
    GameObject dropdownList

    The dropdown list GameObject to destroy

    Remarks

    Override this method to implement a different way to dispose of a dropdown list GameObject.

    DestroyItem(DropdownItem)

    Convenience method to explicitly destroy the previously generated Items.

    Declaration
    protected virtual void DestroyItem(TMP_Dropdown.DropdownItem item)
    Parameters
    Type Name Description
    TMP_Dropdown.DropdownItem item

    The Item to destroy.

    Remarks

    Override this method to implement a different way to dispose of an option item. Likely no action needed since destroying the dropdown list destroys all contained items as well.

    Hide()

    Hide the dropdown list. I.e. close it.

    Declaration
    public void Hide()

    OnCancel(BaseEventData)

    This will hide the dropdown list.

    Declaration
    public virtual void OnCancel(BaseEventData eventData)
    Parameters
    Type Name Description
    BaseEventData eventData

    The associated event data.

    Remarks

    Called by a BaseInputModule when a Cancel event occurs.

    OnDisable()

    Declaration
    protected override void OnDisable()
    Overrides
    Selectable.OnDisable()

    OnPointerClick(PointerEventData)

    Handling for when the dropdown is initially 'clicked'. Typically shows the dropdown

    Declaration
    public virtual void OnPointerClick(PointerEventData eventData)
    Parameters
    Type Name Description
    PointerEventData eventData

    The associated event data.

    OnSubmit(BaseEventData)

    Handling for when the dropdown is selected and a submit event is processed. Typically shows the dropdown

    Declaration
    public virtual void OnSubmit(BaseEventData eventData)
    Parameters
    Type Name Description
    BaseEventData eventData

    The associated event data.

    OnValidate()

    Declaration
    protected override void OnValidate()
    Overrides
    Selectable.OnValidate()

    RefreshShownValue()

    Refreshes the text and image (if available) of the currently selected option.

    Declaration
    public void RefreshShownValue()
    Remarks

    If you have modified the list of options, you should call this method afterwards to ensure that the visual state of the dropdown corresponds to the updated options.

    SetValueWithoutNotify(int)

    Set index number of the current selection in the Dropdown without invoking onValueChanged callback.

    Declaration
    public void SetValueWithoutNotify(int input)
    Parameters
    Type Name Description
    int input

    The new index for the current selection.

    Show()

    Show the dropdown.

    Plan for dropdown scrolling to ensure dropdown is contained within screen.

    We assume the Canvas is the screen that the dropdown must be kept inside. This is always valid for screen space canvas modes. For world space canvases we don't know how it's used, but it could be e.g. for an in-game monitor. We consider it a fair constraint that the canvas must be big enough to contain dropdowns.

    Declaration
    public void Show()

    Start()

    Declaration
    protected override void Start()
    Overrides
    UIBehaviour.Start()

    Implements

    IMoveHandler
    IPointerDownHandler
    IPointerUpHandler
    IPointerEnterHandler
    IPointerExitHandler
    ISelectHandler
    IDeselectHandler
    IPointerClickHandler
    ISubmitHandler
    ICancelHandler
    IEventSystemHandler
    In This Article
    Back to top
    Copyright © 2024 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)