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 mmangual_83 · Dec 05, 2013 at 07:20 PM · c#guigui.box

Changing GUI.Box opacity

How do you change the opacity of a GUI.Box? Is it even possible?

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
7

Answer by BMayne · Sep 01, 2014 at 01:55 AM

Hey There,

All you have to do is go

 GUI.Color = new Color(1.0f, 1.0f, 1.0f, 0.5f) //0.5 is half opacity 
 
 GUI.Box()
 
 GUI.Color = Color.white;

Unity is a state machine so you want to set it back to white when you are done. This GUI.Color effects every GUI element.

Regards,

Comment
Add comment · Show 3 · 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 vexe · Sep 01, 2014 at 04:42 PM 0
Share

That should be the accepted answer

avatar image as87dgs6asg0a · May 25, 2018 at 08:25 PM 0
Share

This doesn't work anymore. It changed the text color ins$$anonymous$$d of the box.

avatar image Bunny83 as87dgs6asg0a · May 26, 2018 at 12:23 AM 1
Share

It always changed both. GUI.color is a global color multiplier which affects both, the background as well as the foreground. In addition there's the GUI.backgroundColor which only affects the background as well as GUI.contentColor which only affects the foreground.

avatar image
0

Answer by MFen · Dec 05, 2013 at 09:32 PM

If you want to change the default GUI.Box you will need to create your own GUISkin inside of the unity editor. Once you have done that click on it and at the top in the inspector window you will see box, change the values of the colors for whatever options you would like. Once you have done that whatever script you are using for GUI, add a holder to put your GUISkin in and in your OnGUI class add GUI.skin = myGUI;

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 mmangual_83 · Dec 09, 2013 at 02:38 PM 0
Share

@$$anonymous$$fen: I am new to this GUISkin stuff. Could you show me some example code and possibly explain this with a more detailed context? Thank you.

avatar image
0

Answer by roryo · Sep 01, 2014 at 01:43 AM

You can make the box more transparent using the opacity in a GUI.Color.

However, to increase the opacity (which is otherwise limited to the opacity of the Box texture image), you can avoid making a new box image and skin by calling the same GUI.Box rectangle multiple times. For example, call the GUI.Box twice and you double its opacity.

 function OnGUI () {
 GUI.Box (Rect (0, 0, Screen.width/7, Screen.height/1), "");
 GUI.Box (Rect (0, 0, Screen.width/7, Screen.height/1), "");
 }

I also posted this hack here: http://forum.unity3d.com/threads/gui-box-transparency.44392/

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

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

21 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

Related Questions

C# GUI Destroy or Disable? 1 Answer

How do you CORRECTLY call methods from another C# file 1 Answer

Using GUI skin with my GUI Button 1 Answer

Using GUI and GUILayout at the same time 1 Answer

creating a list of texture2d components 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