how can i control whether a button is being selected or not?

i have my GUI set up how i want it… but now i want to be able to select a button by using the controller.

i was thinking maybe using an “If…Else…” statement saying if button.hover == true i can press the “A” button to select and activate that button but im not sure what the actual reference is to access if a button is being hovered over or not. what is the actual code for that?

will this work the way i want it to? or is there an easier way of going about doing this?

I’m not fully understanding what you’re trying to accomplish. Are you using a gamepad to move the mouse cursor around or are you trying to cycle through the GUI controls with the gamepad?

trying to cycle through the GUI controls with the gamepad. like your on an actual console like xbox360 or PS3

This in combination with this might do what you’re looking for. Not sure how buttons handle “keyboard input” as the doc is not super clear and only use TextFields as an example, but that should at least get you started.

thanks ill take a look at it.

it seems to me that those would help if i was only going to have a couple buttons on my GUI, but im going to have a full menu of buttons that the gamepad would need to be able to select the buttons before and after the button selected. =\

if those scripts can be used for this i can not figure it out atm… im still kind of a beginner when it comes to scripting =\

It might serve you better then to make “buttons” out of GameObjects with textures attached to them, load those GameObjects into an array that you could then iterate over as the user used the gamepad.

i figured out how im going to do my pause screen, but i need to know how to “activate” a button (like your clicking it) with a button on a gamepad, do you know the syntax for that?

nevermind figured it out, i fixed my problems, thanks for all the help

this is just a theory but it might work.

say you have 4 buttons, assign each a number.

Resume Game - 0
Options - 1
Scoreboard - 2
Exit - 3

you have a variable, lets call it “whichButton”, and assign it 0. now all you have to do is increase or decrease the number according to the input (if the number is to be increased to 4, you would reset to 0, meaning the highlighted button would go from Exit to Resume Game).

the only part I can’t think of a clear way to do is the highlighting.

maybe make an if statement for each of the buttons, and if whichButton is set to their number (say it’s set to 1, then Options would be selected), you will highlight that button. something like this.

var whichButton = 0;

function OnGUI(){

//Create your window

if(whichButton == 0){
//Add a gui element to "highlight" this button, maybe a transparency to be put over top of the button)
}
//Create the Resume Game button (you may have to put this above the if statement above, depending on how you highlight your button.

}

}

and you do that statement for each of the buttons. idk how viable this is but it sounds like it would work…in theory, at least, lol…then when you press say the “A” button, you just check what whichButton is set to, and you run your script accordingly. so if it’s set to 0, resume the game, if it’s set to 1, open the options menu, if it’s set to 2, open up the scoreboard, if it’s set to 3, exit the game.

hope this helped.

Edit: I didn’t read your last post there >.< lol my bad, guess I didn’t get to try to help in time lol.