Search Unity

TextMesh Pro Changing material color from code doesn't update the color of text

Discussion in 'UGUI & TextMesh Pro' started by ArturVector, Mar 10, 2021.

  1. ArturVector

    ArturVector

    Joined:
    Jan 27, 2021
    Posts:
    1
    We are having problem with text color not updating when changing material color from code (changing "_FaceColor"). The material color changes but the text color stays the same.
    Funny thing is that you have to only "touch" the material in editor for the text to update color.

    Unity Version: 2020.2.x (last tested on version 7)
    TextMeshPro version: 3.0.3 and 3.0.4
     
  2. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Since TMP is unaware that you have modified the material, it doesn't know that it needs to update itself.

    Assuming you are modifying the persistent material (ie. not an instance), the color changes should update automatically. However, if this happens to be the material used by a fallback font asset or an instance, then TMP would not be aware of this change.

    After making the material change, see if calling SetMaterialDirty() does resolve the issue.
     
    elguncumayev likes this.