UI Text Won't Change Color in Unity 5

In Unity 5 on Windows 10, I try to change the text color from the Inspector and in scripts, but the color won't change. Here are some screenshots of my Text objects open in the inspector, with there colors set to red and white, but staying the default black in the Scene and Game windows:

Here are the lines of code I am using to change the color

var textColor = beatBestTime ? "#FF0" : "FFF";

scoreText.text = "Time " + FormatTime (timeElapsed) + "\n<color="+textColor+">Best " + FormatTime (bestTime)+"</color>";


which I can verify are being run, but the color remains the same!

• Hmm, well according to the documentation, I would expect to see var textColor = beatBestTime ? "#FFFF00" : "#FFFFFF";. Notice the use of the # in both of the strings, and the usage of the full 6 characters. I'm not entirely sure this is what would fix your issue, but it would be more like what the engine expects. – Vaillancourt Feb 9 '16 at 2:31
• I don't think that is the problem, however I did try it and nothing has changed. – jasper Feb 9 '16 at 2:39

I got stuck on this same thing in this tutorial. My fix was to assign the font material to the text component's material directly underneath where you change it red.

Like user @JaredBrowne says, just go ahead and add the material that was created when you made the "Create Edible Copy".

If it's a bitmap font, you need to make sure that the letters in the sprite sheet are white so that colors will be applied correctly with Unity's default text shader. Most tools, including Unity's "Create Editable Copy," create black letters, but this will lead to the exact symptoms you describe. If you have an existing sprite sheet with black letters, you can just do a quick color replacement in your editor of choice.

• it is a .ttf file, I assume this is not a bitmap font? – jasper Feb 9 '16 at 3:15
• @jasper I've not seen this happen with a TTF, but the process I alluded to would probably work for you. Go to Import settings for the TTF in Unity, hit the gear in the top right, and do "create editable copy." You'll have to fiddle the settings to make it work (hinted raster, ascii default.) Then set that copy as the font for your text, and update the spritesheet that it spit out to have white letters instead of black. If your text still does't colorize, there's likely a shader/material issue. – Nox Feb 9 '16 at 15:07
• Along this line of reasoning, try changing the font temporarily to Arial (or something else built-in) to see if it helps. Should tell you whether there's something awry in the font file or elsewhere in your code/scene. – Chris Mills-Price Feb 9 '16 at 21:54