- Home /
Solved this myself
How are the if's in a GUI.Toolbar handled?
Title explains it,
Since ve've got an array of strings that define the buttons, how do i check if and which button was clicked?
thanks,
bio
You need to pass the current value to the toolbar function. If you pass a constant eg. 0 it will always return 0. How about posting some code? It's quite obvious that the functions works and it does work for most people. If you have problems with it, it almost for certain that you've done something wrong.
We can continue guessing what's your problem but it would make more sense when you show us what you've done.
Wow, calm down.
Why is everybody on UA in rage-mode?
look under warwick's answer, there you got code...
Answer by Waz · Jul 14, 2011 at 01:21 PM
Just as Toggle takes a boolean and returns the new boolean (which changes if the user clicks it), Toolbar takes an int for the current selection and returns the new selection as an int.
Similarly Textfield takes and returns a String.
Well, then why doesn't the integer value change when i click a different button? i'm printing it in Update() to check if it accepts my clicks but it stays zero...is this a known issue?
Show your code - the bug is more likely to be there than in Unity.
You're not doing anything with the return value from GUI.Toolbar.
You should be assigning it to Toolbatint. The GUI.Toolbar docs are pretty clear about this.
I don't care about karma (I wouldn't down vote so much if I did). I care about the quality of this site.
You'll learn a lot faster if you stop assu$$anonymous$$g everything that doesn't work for you is some undiscovered bug or limitation in Unity, and stop thinking everyone who answers you doesn't understand your trivial little problems. Take a look at the smart-Alec responses you've given, to multiple people, all of whom are trying to help you with something they could all write in 10 $$anonymous$$utes and yet which you've foundered with for well over a month. Why don't we just write it for you? Surely that would be faster for us? Because we want karma from the slow trickle of questions? No, because we care that every answer we give helps lift the skill level here, so that eventually you will be answering the next biohazard, or better still, your questions will be of such quality this time that the next biohazard will find them and use the accepted answers directly. That's why we complain about formatting, Q-A structure, good titles, clear code examples, etc.
Ins$$anonymous$$d, you want to hide the answers from the next biohazard by not marking the right answer. If you prefer, you can answer your own question if you've solved it - mark it accepted and everything, we don't $$anonymous$$d (though it might look a little childish).