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
0
Question by HHameline · May 09, 2011 at 06:14 PM · texturecustom

Creating a GUI.Toolbar with Custom GUIStyle

Hello, I was wondering if it was possible to create a toolbar with 5 buttons each button having a unique mouse over, pressed and not pressed texture. I tried to do this with the following code but after much tinkering it still is not working.

category = GUI.Toolbar(new Rect(5, 5, SHOP_WIDTH - 10, 85), category, categoryName, categoryButtons);

Where category is an int. categoryName is a list of strings. categoryButtons is a list of GUIStyles.

categoryButtons = new GUIStyle[] { mySkin.FindStyle("TB1Button"), mySkin.FindStyle("TB2Button"), mySkin.FindStyle("TB3Button"), mySkin.FindStyle("TB4Button") };

Any ideas?

Thanks Hans

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

3 Replies

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

Answer by Jake-L · May 09, 2011 at 07:36 PM

According to the docs GUI.Toolbar doesn't take an array of GUIStyles, so you only can provide one. I think you have two options:

  1. Try how it looks when you feed GUI.Toolbar with an array of GUIContent that hold your images
  2. Create your own toolbar: Draw each button on it's own, so you have full control over it's appearance

Jake

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 HHameline · May 09, 2011 at 08:12 PM 0
Share

Thanks Jake, greatly appreciated. I fooled around with the unity GUI.Toolbar enough now where I think its time to go with your second suggestion and cut my losses and make my own toolbar. Thanks again.

avatar image
-2

Answer by Dave 11 · May 09, 2011 at 07:05 PM

I've got no idea

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 HHameline · May 09, 2011 at 07:11 PM 0
Share

Thanks for that incredibly helpful comment. :/

avatar image Dave 11 · May 09, 2011 at 09:53 PM 0
Share

No problem :) Glad you liked it.

avatar image
0

Answer by beco13 · Jun 28, 2011 at 03:49 AM

@HHameline : sorry to interrupt, does your problem solved? I also have the same problem...But I've already got each button unique style, how do I implement it into the toolbar scripts? Thx

Comment
Add comment · Show 4 · 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 HHameline · Jun 28, 2011 at 04:00 AM 0
Share

Hello, beco13 :D Unfortunately there is no built in way to handle the unique images with the GUI.Toolbar function what you can do is create a group of GUI.Toggles, and using boolean values disable the ones that are not pressed, give the same functionality of a toolbar even if it is longer. How ever it's stable and worked great for me.

avatar image beco13 · Jun 28, 2011 at 04:09 AM 0
Share

I see so the unity doesn't provide the way :)

and how do I do that? I mean setting up the boolean and disabling the others.

avatar image HHameline · Jun 28, 2011 at 04:15 AM 0
Share

You would want to do something along these lines

bool boolA; bool boolB;

if (GUI.Toggle(new Rect(70, 165, 217, 133), boolA, "")) { boolA = true; boolB = false; }

if (GUI.Toggle(new Rect(70, 305, 217, 133), boolB, "")) { boolA = false; boolB = false; }

this is a very simple way of doing it, for instance the one I mad I used custom gui styles with the toggles and a switch statement to control my menu page options but it the the foundation for what you are trying to do. Hope that helps :d

avatar image beco13 · Jun 28, 2011 at 04:20 AM 0
Share

@HHameline : That really2 does help :) thx for your advice I tried the switch statements, but can't figure it out.. LoL

Once again thank you very much

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

Assigning UV Map to model at runtime 0 Answers

Custom score texture 2 Answers

How to texture custom terrain pieces? 1 Answer

Cannot paint Texture onto Terrain using Custom Material 2018.4 1 Answer

Create a custom texture from code? 1 Answer


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