- Home /
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)?
Answer by iamlowlikeyou · Sep 13, 2018 at 10:43 AM
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.
Answer by Legend_Bacon · Sep 13, 2018 at 10:40 AM
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
Thanks for your input!
I'll look into that plugin, I might need it for something else later :-)
Your answer