Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

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

Discussion in 'UGUI & TextMesh Pro' started by cloverme, Apr 26, 2022.

  1. cloverme

    cloverme

    Joined:
    Apr 6, 2018
    Posts:
    199
    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.

     
  2. charlie_unity331

    charlie_unity331

    Joined:
    Nov 2, 2021
    Posts:
    1
    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.
     
    AnasBayu and gomezmatiasagustin like this.
  3. gomezmatiasagustin

    gomezmatiasagustin

    Joined:
    Apr 7, 2023
    Posts:
    1
    Thanks, i was not able to find an answer to my text color not being changed, OAAAA
     
  4. JavaScript9x

    JavaScript9x

    Joined:
    Dec 5, 2022
    Posts:
    2
    It's not work with me.


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

    Korsigon

    Joined:
    Oct 6, 2014
    Posts:
    16
    myTextMeshProUGUIComponent.color = new Color32(241, 160, 118, 255);
     
  6. Qwolf0521

    Qwolf0521

    Joined:
    Jan 5, 2015
    Posts:
    2
    Maybe try these two methods, this worked for me.

    Code (CSharp):
    1.     public TMP_Text text;
    2.     public Color color;
    3.  
    4.     private void Start()
    5.     {
    6.         text.faceColor = color;
    7.     }

    Code (CSharp):
    1.    public TMP_Text text;
    2.     public Color color;
    3.  
    4.     private void Start()
    5.     {
    6.         text.enableVertexGradient = true;
    7.         text.colorGradient = new VertexGradient(color);
    8.     }
     
  7. EricVoll

    EricVoll

    Joined:
    Apr 22, 2017
    Posts:
    4
    Not a big fan of this solution, but this worked for me. `Override Tags` does not have to be true.
    Code (CSharp):
    1.         for (int idx = 0; idx < _textComponent.textInfo.materialCount; ++idx)
    2.         {
    3.             int numColors = _textComponent.textInfo.meshInfo[idx].colors32.Length;
    4.             for(int ci = 0; ci < numColors; ++ci)
    5.             {
    6.                 _textComponent.textInfo.meshInfo[idx].colors32[ci] = newColor;
    7.             }
    8.         }
    9.         _textComponent.UpdateVertexData(TMP_VertexDataUpdateFlags.Colors32);