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 TroubledTurtles · Jan 11, 2015 at 06:05 PM · uibuttontextcolorunity 4.6

How To Change Color Of Text On UI When It's Selected | Unity 4.6

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 · Show 1
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 dr3th · Mar 20, 2015 at 06:09 AM 0
Share

The font should change colour the way you've described it. I am assu$$anonymous$$g you have a normal text component then you've added a button to the text component? Then you've changed the tints accordingly. That should work fine.

3 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by amisane · Nov 19, 2016 at 07:03 AM

I achieved this with minimal effort by adding a script to my button and implementing ISelectHandler and IDeselectHandler

 public class ButtonTextColorChangeScript : MonoBehaviour, ISelectHandler, IDeselectHandler {
 
     void ISelectHandler.OnSelect(BaseEventData eventData)
     {
         gameObject.GetComponentInChildren<Text>().color = new Color(255, 255, 255, 255);
 
     }
 
     public void OnDeselect(BaseEventData eventData)
     {
         gameObject.GetComponentInChildren<Text>().color = new Color(0, 0, 0, 255);
 
     }
 }
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 LordScottWarren · Oct 12, 2017 at 11:41 AM 0
Share

I have implemented this however for some reason it only seems to work with setting the color to (0,0,0,255) if i want to use a different color its not working! :( any idea why?

avatar image
-3

Answer by UNZoOM · Mar 19, 2015 at 10:55 PM

 To change the color of the text itself.
 
 Select the Text under the Button in the canvas which looks like following : 

alt text

And then you can change the color here as shown below :

alt text


capture.jpg (30.0 kB)
cap1ture.jpg (9.6 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
avatar image
0

Answer by DiegoSLTS · Mar 19, 2015 at 08:29 PM

You can do that making animation clips for each state (changing the background image and text color) and setting the Transition to Animation. That's the most flexible way of doing things with the Button component, each animation could affect multiple objects and values.

Another option would be to remove the Button component and add an Event Trigger component. With that component you can setup callbacks for each UI event, and those callbacks can trigger functions in any gameobject. This let you do more stuff than the "Transition -> Animation" method since you're not tied to animations, but it takes some extra work to set it all up.

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Easily recolorable Button background textures 1 Answer

Find GUI Button and Assign Text 1 Answer

How to change text color on hover in new GUI? 10 Answers

Destory button on click and other problem 0 Answers

How do I invert the color of ui text to make it more readable, on a messy background? 4 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