UI Text background color

I have a Text (script) UI element.

How do I add a background color to the text (i.e. a colored block behind the text just like if you select a portion of text in your standard text editor)?

Okay, so as usual, after sitting with this for hours, I discover the solution myself 20 minutes after posting the question.

I simply added an Image (script) component to the Rect Transform that my Text element is inside, and then defined a color.

Still kind of weird that you cannot simply add a background color to the Text component itself though.

Hello there,

As far as I know there is no way to do this with the default Unity Text.

However, you can use the Text Mesh Pro plugin to handle text highlighting, as described on this thread.

It’s a free plugin now since Unity bought it, and is included by default with the newer versions of Unity. It’s pretty awesome, too.

Hope that helps!

Cheers,

~LegendBacon

I find this

1 Like