Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

[SOLVED] set color of TextMeshPro.faceColor works with Color.red but now with new Color(r,g,b)

Discussion in 'Scripting' started by Dustyguy, Aug 23, 2020.

  1. Dustyguy

    Dustyguy

    Joined:
    May 13, 2015
    Posts:
    5
    Trying to set the color of a TextMeshPro.faceColor. works fine when i use:

    text.faceColor = Color.red;


    but does not work with:

    text.faceColor = new Color(255, 162, 90, 255);
     
  2. mopthrow

    mopthrow

    Joined:
    May 8, 2020
    Posts:
    343
    Hey,

    Color() constructor takes floats and needs rgba values between 0 and 1.0f, but you gave it bytes (0 to 255).

    Try Color32() if you want to set byte values.

    Code (CSharp):
    1. text.faceColor = new Color32(255, 162, 90, 255);
     
    fergamboa_ and Dustyguy like this.
  3. Dustyguy

    Dustyguy

    Joined:
    May 13, 2015
    Posts:
    5
    Awesome thx
     
    mopthrow likes this.