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 Zikku · Sep 29, 2012 at 10:14 PM · guicolorbackgroundguiskin

Can I use hexidecimal colors in my GUI?

I'm creating a starting page where a participant enters some information like their name, birth date, and gender. I wanted to use a drop-down menu so they can just select their birth month from a list. I did some research on how to go about doing that in the GUI (I'm using JavaScript for Unity), but the default background on the GUI style is semi-transparent. I wanted to change it so it was more opaque because if there were words under the drop down list, you couldn't read them very well. I did some research on that and successfully changed the normal background as well. My problem is now that with the text being white and/or black, using a gray isn't very aesthetically pleasing and using black will make the previously chosen option unreadable.

I tried playing around with a few other colors like in CSS, but Unity doesn't read those (my go-to test color is teal). I've been trying to find an answer to this before I posted it, and I'm stumped. I can't even find a list of colors that Unity accepts by name. Here is a snippet of the current code.

 // Make a GUIStyle that has a solid white hover/onHover background to indicate highlighted items
         listStyle = new GUIStyle();
         listStyle.normal.textColor = Color.white;//Text colour of list
         //Hovering BG
         var texHover = new Texture2D(2, 2);
         var colorsHover = new Color[4];
         for(color in colorsHover)color = Color.white;//Hover BG colour of list
         texHover.SetPixels(colorsHover);
         texHover.Apply();
         //Normal BG
         var texBG = new Texture2D(2,2);
         var colorsBG = new Color[4];
         for(bgColor in colorsBG) bgColor = Color.gray;//Normal BG color of list
         texBG.SetPixels(colorsBG);
         texBG.Apply();
         //Apply Textures to List Style
         listStyle.hover.background = texHover;
         listStyle.onHover.background = texHover;
         listStyle.onNormal.background = texBG;
         listStyle.normal.background = texBG;
         listStyle.padding.left = listStyle.padding.right = listStyle.padding.top = listStyle.padding.bottom = 4;

You can see in the 13th line down is where I define what color is in the background of the drop down menu. I'm not too keen on GUI skins to begin with, so I'm quite sure there is something very basic that I'm missing. Basically, I want the background a dark gray.

Here are two screenshots of the GUI list (first one in gray, the second one in black): GUI with Gray Dropdown

GUI with Black Dropdown

2.png (18.7 kB)
3.png (17.6 kB)
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
3
Best Answer

Answer by ThermalFusion · Sep 29, 2012 at 11:46 PM

http://docs.unity3d.com/Documentation/ScriptReference/Color.Color.html Create any color using floating point rgba values. If you search the documentation for Color, you will find the list of the prenamed colors here: http://docs.unity3d.com/Documentation/ScriptReference/Color.html You can also use Color32 if you'd rather input colors in the usual 0-255 integer range.

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 Zikku · Oct 04, 2012 at 09:28 PM 0
Share

Thank you very much! Exactly what I was looking for.

I knew it would be something basic that I was missing! $$anonymous$$uch appreciated.

For anyone else that comes upon this, here's the documentation for the color32 stuff. http://docs.unity3d.com/Documentation/ScriptReference/Color32.html

That was exactly what I was looking for because I can easily open photoshop, use the color picker to find whatever I need, and the RGB values are listed right there, 0 to 255.

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

11 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

Related Questions

Specify background color of Gui.Button at runtime 1 Answer

Changing the color of a GUI element 1 Answer

Change color of Gui.Box background to solid black 1 Answer

Change Background Color of ScrollView? 2 Answers

How do I make a colour editor UI? 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