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 /
  • Help Room /
avatar image
1
Question by FuryFight3r · Jan 17, 2017 at 06:20 PM · textcolorsizeonguicolor change

OnGUI() Text Color through c# script

Hi there, been stuck on this for a while, searched possibly every question in relation to this and cannot find anything that will help nor work..

what i am trying to achieve is make the Text bigger, which is done by the guiStyle, but after doing this, it turned the text to Black from white, and i have a dark Horror scene so the text is now unreadable, it was near unreadable being the default size, and now it is a good size to read, but it has turned black and has become unreadable in that way...

and once again, i have searched around and tried many different ways, with GUISkins (which if someone could provide a good way to use these, as the Unity source code page on this did not help me much), using GUI.color = Color.white, i believe it is the guiStyle that is overwriting the color to be black, just wondering how i can either default it back to the default white or change it somewhere to allow it to be white in my coding?

     private GUIStyle guiStyle = new GUIStyle();
 
     void OnGUI()
     {
         GUI.color = Color.white;
         guiStyle.fontSize = 20;
         //have tried GUI.color here

         if (isRinging)
         {
             //have tried GUI.color here

             GUI.skin.label.alignment = TextAnchor.UpperLeft;

             //have tried GUI.color here

             GUI.Label(new Rect(10, 10, 1500, 900), "Task: Answer The Phone.", guiStyle);
         }
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
1
Best Answer

Answer by Glurth · Jan 17, 2017 at 06:41 PM

I suspect this issue is due to the fact that you create a new GUIStyle, and use it for your label, but you do NOT assign this style a specific color. Since creating it yourself, you actually need to define the color for each GUIStyleState in the GUIStyle (normal, hover, etc..). e.g.

 guiStyle.normal.textColor= Color.white;

Regarding GUI.color, I suspect you meant to use GUI.contentColor. But I think the GUIStyles is the better way to go.

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 FuryFight3r · Jan 17, 2017 at 06:47 PM 0
Share

Excellent, thanks very much, i was trying my best to work this out, i did try similar code to that, but without the .normal. that's where my problem was, thank you!

EDIT: and yes i did actually try and use GUI.contentColor, but that had no effect, but as we had both suspected i believe the guiStyle was overwriting the color.

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

90 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 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 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 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 avatar image avatar image

Related Questions

Animating Colors fails 0 Answers

How do i make an Image flash 2 colors, 1 Answer

TextBox.Color C# logic not working for two assets at once 0 Answers

Is there any way to make a gradient within unity?,Is there any way to make a gradient? 1 Answer

How to make a TextMeshPro Object perfectly fit his RectTransform's height ? 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