UI Text as Button


I'm playing around with the new UI and was wondering, if there is a possibility/script to make a text element behave like a button, or do i have to give the button a transparent image?
Furthermore the ColorTint button transition is great but it would be even better if there would be some way to apply it also to the attached text!?

If you have a game object with your Text component, just add a Button component. A button doesn't rely on an image. The Color Tint will automatically use the Text for the transitions.

1 Like

Thats neat! Still the question remains if I add a standard button, that has an image, the color tint is only applied to the image and not the button text...

Drag the Text game object into the Graphics Target slot of the Button.

If you want to affect more than one object, you may use an animation. You need to switch the Transition from ColorTint to Animation in that case.


it would be awesome if these button GO (parented to text GO) could affect text inside button rect only (instead of affect all text) - this would solve all problem with rich text (event firing included) because GO allow have multiple childrens. It would be way clearer than string rich text i think. of course it would need a bit different workflow and maybe new button type. However its impossible right now until someone create custom open source uGUI or Unity implement this

Much better/flexible solution would be to have an array of Graphic as a target of Tint transition.

It is not a big deal to create such a component on your own.

Not sure what you mean: create a custom Button script with array for Tint transition?

Yes. You could even try deriving your script from the built-in Button and see if you can override just the parts that deal with doing color changes…

Well, of course I can do it, and probably will (or may be will write some component which propagates color to its children), but using an array works the same like now, but just gives additional flexibility (imagine you have button with text and icon and you want them both to be tinted on press/hover/etc or some complex button background which consists of few elements).

I understand that this is more flexible, but it is still understandable to me why there are just a few options. If you need total flexibility, you can use the animation component. As soon as you look for something that is easy to set up and is supposed to be flexible, it will work in some cases and in others it won’t. You may e.g. say that and array of graphic targets would be sufficient, that’s fine. Then someone else thinks, why can’t I have an array of such transitions, but each of them needs an array of graphics targets, such that a group of objects gets the same colors for the transition, but another group has its own colors.
I really see your point, but I believe it makes a lot of sense like that.