How do you change the "Vertex Color" on the TextMeshPro UI component?

Tried everything I could think of through code and google results aren’t working. There’s a bunch of stuff out there referencing color vs color32, but doesn’t seem to matter. There’s also a bunch of .color nested properties but can’t locate the one to change it.

Had the same problem. Changing the “overrideColorTags” property to True on the TextMeshProUGUI component allowed the colors to change for me.

[textmeshprouguicomponent].overrideColorTags = true;
then change the colors
[textmeshprouguicomponent].color = new Color32(…);

Alternatively you can also just check off the “Override Tags” box in the component in the inspector.

2 Likes

Thanks, i was not able to find an answer to my text color not being changed, OAAAA

It’s not work with me.

myTextMeshProUGUIComponent.overrideColorTags = true;
myTextMeshProUGUIComponent.color = new Color(241, 160, 118, 255);

myTextMeshProUGUIComponent.color = new Color32(241, 160, 118, 255);

Maybe try these two methods, this worked for me.

    public TMP_Text text;
    public Color color;

    private void Start()
    {
        text.faceColor = color;
    }
   public TMP_Text text;
    public Color color;

    private void Start()
    {
        text.enableVertexGradient = true;
        text.colorGradient = new VertexGradient(color);
    }

Not a big fan of this solution, but this worked for me. Override Tags does not have to be true.

        for (int idx = 0; idx < _textComponent.textInfo.materialCount; ++idx)
        {
            int numColors = _textComponent.textInfo.meshInfo[idx].colors32.Length;
            for(int ci = 0; ci < numColors; ++ci)
            {
                _textComponent.textInfo.meshInfo[idx].colors32[ci] = newColor;
            }
        }
        _textComponent.UpdateVertexData(TMP_VertexDataUpdateFlags.Colors32);