Search Unity

Question Open Dropdown by keyboard?

Discussion in 'UGUI & TextMesh Pro' started by exe2k, Dec 1, 2021.

  1. exe2k

    exe2k

    Joined:
    Oct 26, 2015
    Posts:
    63
    Im trying to control UI without a mouse. Stuck at dropdowns. How can I expand them from script?

    Code (CSharp):
    1. public class DropDownOpener : MonoBehaviour
    2. {
    3.  
    4.     TMP_Dropdown dd;
    5.  
    6.     private void Start()
    7.     {
    8.         dd =  GetComponent<TMP_Dropdown>();
    9.     }
    10.     void Update()
    11.     {
    12.         if (Input.GetButtonDown("Accept") )
    13.         {
    14.  
    15.             dd.Show();
    16.             Debug.Log("openes");
    17.         }
    18.     }
    19. }
    that does nothing(
     
  2. northman

    northman

    Joined:
    Feb 28, 2008
    Posts:
    144
    I got same problem. UP!