Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 /
avatar image
-1
Question by NutellaDaddy · Mar 12, 2014 at 12:55 AM · c#guitoolbar

How do I make and use a GUI Toolbar in C sharp?

I want to make a gui toolbar so i can go between 3 different menus using tabs. How can I do this. How do I even make a toolbar? Do I have to make it so that my variables that control the inventory on and off go on when you click one of the bars? Can someone please help!

Comment
Add comment · Show 7
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 getyour411 · Mar 12, 2014 at 12:59 AM 0
Share

"How I make GUI?" comes off as a little lazy. What's a toolbar to you - a GUI.BOX? You can do that. What are menus, things that appear when if(GUI.BUTTON) is pressed? You can do that. How do I write something that is on/off on click - thats if(true) showStuff - you can do that.

Please revise if you have a specific technical question.

avatar image NutellaDaddy · Mar 12, 2014 at 01:29 AM 0
Share

No there is a GUI thing...I don't know what to call it that is actually a GUI.Toolbar and I don't know how to use it.

avatar image getyour411 · Mar 12, 2014 at 01:33 AM 0
Share

http://docs.unity3d.com/Documentation/ScriptReference/GUI.Toolbar.html

http://lmgtfy.com/?q=unity3d+gui.toolbar#

avatar image NutellaDaddy · Mar 12, 2014 at 01:54 AM 0
Share

It doesn't really explain how to do anything with the toolbar other than create it. I looked there first.

avatar image NutellaDaddy · Mar 12, 2014 at 01:55 AM 0
Share

Let me try something and I'll get back to you.

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Sildaekar · Mar 12, 2014 at 03:33 AM

The documents located at http://docs.unity3d.com/Documentation/ScriptReference/GUI.Toolbar.html explain the Toolbar's usage and creation process.

Take a look at the example code:

 using UnityEngine;
 using System.Collections;
 
 public class Example : MonoBehaviour {
     public int toolbarInt = 0;
     public string[] toolbarStrings = new string[] {"Toolbar1", "Toolbar2", "Toolbar3"};
     void OnGUI() {
         toolbarInt = GUI.Toolbar(new Rect(25, 25, 250, 30), toolbarInt, toolbarStrings);
     }
 }

In this code, when Toolbar 1 is selected toolbarInt is set to 0, when Toolbar2 is selected toolbarInt is set to 1. Etc etc..

Just use the integers to determine what menu you are in.

So you could use it like this:

     using UnityEngine;
     using System.Collections;
     
     public class Example : MonoBehaviour {
         public int toolbarInt = 0;
         public string[] toolbarStrings = new string[] {"Main Menu", "Options", "Exit"};
         void OnGUI() {
             toolbarInt = GUI.Toolbar(new Rect(25, 25, 250, 30), toolbarInt, toolbarStrings);
             
             if(toolbarInt==0){
                 Debug.Log("This is the main menu!");
             }else if(toolbarInt==1){
                 Debug.Log("This is the options menu!");
             }else if(toolbarInt==2){
                 Application.Quit();
             }
         }
     }

Comment
Add comment · Show 1 · 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 Sildaekar · Mar 13, 2014 at 03:59 PM 0
Share

If this answers your questions please don't forget to mark this answer :)

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

22 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to make spaces in between Gui boxes being made in for loops? 1 Answer

GUI.Button To Change Weapons On Screen 2 Answers

Add a GUIBox if Key picked up 2 Answers

How could I create a stamina bar. I keep on trying and nothing works. 1 Answer

Detecting Which Button is Pressed on a Toolbar 2 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