Search code examples
c#unity-game-enginescrollview

Auto-scroll content with selected item


I have a dropdown menu, which is working fine using a mouse or touch:

enter image description here

But, I would like to also allow the keyboard or joystick to control it.

I can select the dropdown items and navigate, you can notice the fourth item is selected ("Atlantis" in red).

But, if I go down to the next item bellow it--using only keyboard for example--the content doesn't scroll down automatically.

How can I do that?


Solution

  • Well, I solve this way

    if (Input.blablablagetbuttondown)
    {
        TemplateViewPortContentRectTransform.anchoredPosition += new Vector2(0,
        TemplateViewPortContentItemRectTransform.sizeDelta.y);
    }
    

    With some name changes to explain better what are the objetcs... And equivalent code to go up.