Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
This question was closed Jul 14, 2011 at 01:46 PM by biohazard for the following reason:

Solved this myself

avatar image
0
Question by biohazard · Jul 14, 2011 at 01:03 PM · javascriptguiiftoolbar

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

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Bunny83 · Jul 14, 2011 at 01:30 PM 0
Share

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.

avatar image biohazard · Jul 14, 2011 at 01:33 PM 0
Share

Wow, calm down.

Why is everybody on UA in rage-mode?

look under warwick's answer, there you got code...

1 Reply

  • Sort: 
avatar image
2

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.

Comment
Add comment · Show 10 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image biohazard · Jul 14, 2011 at 01:22 PM 0
Share

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?

avatar image Waz · Jul 14, 2011 at 01:29 PM 0
Share

Show your code - the bug is more likely to be there than in Unity.

avatar image Waz · Jul 14, 2011 at 01:34 PM 1
Share

You're not doing anything with the return value from GUI.Toolbar.

avatar image Waz · Jul 14, 2011 at 01:35 PM 1
Share

You should be assigning it to Toolbatint. The GUI.Toolbar docs are pretty clear about this.

avatar image Waz · Jul 14, 2011 at 02:12 PM 1
Share

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).

Show more comments

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Playing audio when a button is clicked? 1 Answer

onGui - Switching between textures on selection grid. 0 Answers

I am having an issue with returning an array 2 Answers

3 sets of button activations GUI 1 Answer

if ((this || that) && (that || this)).. Does that work? 3 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges