I’m hoping there’s a relatively easy way to do this through GUI buttons…I have created an arbitrary number of buttons (amount of buttons chosen in the inspector) in a for loop. Right now, they are all labeled "Button " + i.ToString, giving me Button 0 through Button 9 if I set the variable NumberOfButtons to 10.
What I’d like to be able to do us use my game pad to cycle through the buttons…as I use the horizontal axis, the next button is highlighted. If I press “fire 1”, for instance, that highlighted button will activate.
I understand how to make single buttons, and I understand how to make them execute code when pressed with a mouse, but this is beyond me to set up. So far, I have the for loop in the GUI and that is about it…
for (var i=0;i>numberOfButtons;i++)
{
GUI.Button(Rect(8+(i*100),64,60,60), "Button " +i.ToString());
}
This works fine, but where do I go from here in order to have the first button be ‘selected’ as if the mouse is hovering from the start, and then how do I scroll through the selection using my gamepad?
I know there’s a lot to the question, but thanks so much for the help!