Search Unity

TextMesh Pro TMPro Text Color only updates in-game to certain colors?

Discussion in 'UGUI & TextMesh Pro' started by N1ghtrunner, Nov 27, 2022.

  1. N1ghtrunner

    N1ghtrunner

    Joined:
    Jan 5, 2015
    Posts:
    104
    I have a simple timer running in my game, and when the clock gets below a certain amount of time remaining, I want to change the color of the TMP text object on the canvas to a red color.

    Code (CSharp):
    1.         if (minutes == 2 && seconds < 55)
    2.         {
    3.             timerText.color = new Color(195f, 15f, 22f, 255f);
    4.             Debug.Log("Updating color");
    5.         }
    Now that is the red color I am going for, however in game the text continues to display as default/white text.

    However, if I update the Color values to timerText.color = new Color(255, 0f, 0f, 255f);.....then it works, and changes the color to a less-than-ideal red. Is there a reason for this? Am I missing something here?
     
  2. N1ghtrunner

    N1ghtrunner

    Joined:
    Jan 5, 2015
    Posts:
    104
    Ok so for future reference for anyone, this is because I was using Color and not Color32. Color32 doesnt require float values either and appears to be better in this use case.