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 /
avatar image
0
Question by bibbinator · May 31, 2011 at 05:10 AM · toolbar

How to enable/disable individual toolbar items?

Normally I can set the GUI.enabled state to cause the controls to be drawn in a disabled state if needed.

But GUI.enabled = false will cause the entire GUILayout.Toolbar to show as disabled. How can I disable and enable individual items?

Cheers

Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
2

Answer by yoyo · May 31, 2011 at 05:30 AM

GUILayout.Toolbar doesn't have an option to enable/disable individual items. If you're using images instead of text you could pass in a different image when a particular button is disabled.

But probably better to use GUILayout.BeginHorizontal instead, then insert buttons one by one with GUILayout.Button. Use the style parameter to control how they look, and ignore clicks on buttons you want disabled.

Comment
Add comment · Show 2 · 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 bibbinator ♦♦ · May 31, 2011 at 10:42 AM 0
Share

Thanks for your answer. That's what I thought, bummer. Cheers.

avatar image caLLow · Jun 10, 2015 at 10:03 PM 0
Share

Used toolbar at first but with a little styling you can achieve a much better 'custom' look and improved functionality.

Example of my usage:

     //Before with no custom functionality
     //tabIndex = GUILayout.Toolbar(tabIndex, m_TabNames);
     
     
     //After with total control
     GUILayout.BeginHorizontal(GUILayout.$$anonymous$$inHeight(21));
     {
         GUI.enabled = ValidWaypoints.Length >= 2 && tabIndex != 0;
         if(GUILayout.Button(TabSettings.tabNames[0], EditorStyles.$$anonymous$$iButtonLeft, GUILayout.ExpandHeight(true)))
         {
             tabIndex = 0;
         }
         GUI.enabled = ValidWaypoints.Length >= 2 && tabIndex != 1;
         if(GUILayout.Button(TabSettings.tabNames[1], EditorStyles.$$anonymous$$iButton$$anonymous$$id, GUILayout.ExpandHeight(true)))
         {
             tabIndex = 1;
         }
         GUI.enabled = ValidWaypoints.Length >= 3 && tabIndex != 2;
         if(GUILayout.Button(TabSettings.tabNames[2], EditorStyles.$$anonymous$$iButtonRight, GUILayout.ExpandHeight(true)))
         {
             tabIndex = 2;
         }
         GUI.enabled = enabled;
     }
     GUILayout.EndHorizontal();

alt text

Thanks yoyo!

custom-toolbar.png (2.4 kB)

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

2 People are following this question.

avatar image avatar image

Related Questions

Unselecting a toolbar 1 Answer

GUI Texture in toolbar (C#) 1 Answer

I dont see EasyRoads menu 1 Answer

Activating another scene's script? 1 Answer

Editor: Drawing outside the own window 0 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