- Home /
Unity GUI Button Options
I'm new to using Unity and I have a question about GUI.buttons. I know that these are one time events that do an action upon one click. My goal is to have a sort of settings for the game graphically using these buttons. However, I cannot think of a visual representation of this.
For example, say for a game, at the starting menu, I can choose to set bullets for something to be infinite or limited. There are two thus two buttons to graphically represent this. By default, the game settings have limited set to on; a bool that is set to true. Graphically, this would show as a button being pressed down and stays down. If I were to press the other button to set the amount of bullets to infinite, this button would graphically be shown as pressed down while the other is shown in a default non pressed button.
I'm looking through possible Unity options and it seems I cannot do this.
Another possibility I'm thinking is to using GUI.Button like normal, and when the button is pressed once, the color of the text on the button changes to signify that it has been chosen and the overall bool is true for the game. I believe this is possible but I need confirmation. Thanks.
You can use GUI.Toggle() (though it is not a perfect match)
You can dynamically change the texture on a button based on state.
You can dynamically change the GUIStyle of a button
You can implement your buttons as GUITextures and use On$$anonymous$$ouseDown() to get the click.
You can implement your buttons as Quads and use Raycasting or On$$anonymous$$ouseDown() to get the click.
Note that NGUI and EZGUI make doing something like this far easier, but they cost $$. Apparently a new GUI system is in the works for Unity based on NGUI.
Your answer
Follow this Question
Related Questions
3D Button? 1 Answer
Disable one GUI Button with my Mouse Scroll Wheel? 1 Answer
Unity android button and Time.timescale problems 1 Answer
How to give animation to the on gui button? 1 Answer
Help with GUI clicking ??? 1 Answer