How would I make a menu that scrolls with dpad down on controller?

I created my menu and everything, but im really bad at scripting in JS and C#. So if anyone could write up a code or a bit of code that will make things easier for me that wold be great.

Also I wanted to include a red background for the text so when dpad down is pressed the red box/background goes down to the next text. <---- Im only worried about my first question for now, but this would also save me a bit of time.

Thanks people of unity! :smile:

A few hints :
-Maintain a list of items (your menu entries).
-Maintain the current selection index (your item red background box)
-In the OnGui() callback, draw your menu and the selected item (with GUI.Label(), GUI.DrawTexture()…)
-In the Update() callback, check your dpad and increment or decrement your current selection index (Don’t forget the wrapping :slight_smile: )

And when you’re done with this, wrap this into a nice c# or js class to be easily reusable on your next projects.
:slight_smile:

With D-Pad, it’s axis-based control so there is no button down or button up. You’d have to either

  • Create a polling and keeping current and previous d-pad state by yourself, to simulate button down/up function
  • Or use coroutine when getting axis input, so there is some delay between pressing a d-pad, and holding one direction won’t end up in cursor moving so fast like crazy