text colour no changing

Having a problem changing text colour via script. Should be pretty simple. All I’m doing is this:

message_box.GetComponent<TMPro.TextMeshProUGUI>().color = new Color(0f, 127f, 212f, 255f);

I’ve got the textmeshpro “color mode” set to single not gradient. Tried changing vertex color. Didn’t work either.
I can change it in inspector during game view, but as I say it won’t change via script. I’ve checked everywhere that I’m not changing it somewhere else. I’m not.

Any ideas?

Firstly, wrong sub forum.

Secondly, Colour uses values from 0 to 1: Unity - Scripting API: Color

Colour32 uses byte values from 0 to 255: Unity - Scripting API: Color32

Be sure to consult the docs in future.

2 Likes

Color32 …that’s the bit I forgot. :slight_smile: Cheers

1 Like