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 dpw · Sep 03, 2014 at 09:12 PM · guicolorfontart

New UI system 4.6, how to change font color?

How do I change the font's color when Normal/HighLighted/Pressed/Disabled in the new UI system for unity 4.6? The Button -> Transition -> Color Tint will just change the BUTTON'S color, and not the font itself. Any idea on how I could do that? :)

Thanks in advance, peace! :)

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

2 Replies

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

Answer by FredZvt81 · Sep 03, 2014 at 09:44 PM

When you create a button there are actually two objects being created, one for the button background image that has the Button component attached and a child object for the text representation that has the Text component attached.

You have to change the color in the Text component of the child object in order to change the button label color.

If you want to change the label color only when the button is pressed or on mouse hover, you have two options: use the animation transition in the Button component and animate the color of the child object's text component or create a custom script. In my opinion, using the animation transitions is the easiest option.

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 dpw · Sep 06, 2014 at 03:29 AM 1
Share

thank you for the helpful reply :)

avatar image
0

Answer by ReneBuehling · Nov 28, 2015 at 03:26 PM

Although this question is a year old and has an answer, I want to add my solution for the files as I feel it is still relevant. I created a script that copies the button's current color into any child Graphic component, i.e. text or images.

Problem Illustration

As the button's "current color" resulting from its tint transition can not be obtained from the Button, the relevant trick is to access the button's CanvasRenderer instead. This component contains a color property which holds the current transition color:

 ...
 void Update () 
 {
 ...
        //target is any Graphic component (Text, Image, ...)
         //target.color=button.GetComponent<CanvasRenderer>().GetColor();
         target.color=button.targetGraphic.canvasRenderer.GetColor();  
 ...
 }
 ...
 

I made a simple drag and drop ready script, that can be downloaded on my website. Usage: Create a button that contains text and/or image child elements. Drop my script to each child of the button (text, image, ...) that you like to have the button's color state adopted.


Edit: Fixed to use targetGraphic's renderer instead of buttons renderer which is (at least) required in Unity 5.3.1f1+.


unity-button-targetgraphic-problem-en.jpg (90.5 kB)
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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

How to change font color 4 Answers

How do I change the font and color of GUI text? 0 Answers

How do I change the font and color of GUI text? 1 Answer

Script loads font, how do I change the color? 2 Answers

Color.white not so much white... 3 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