G
G
Gregory2562021-08-07 16:07:43
Unity
Gregory256, 2021-08-07 16:07:43

How to change TextMeshPro text color?

Tried via GetComponent , but the error

"ArgumentException: GetComponent requires that the requested component 'Color' derives from MonoBehaviour or Component or is an interface.
UnityEngine.GameObject.GetComponent[T] () (at :0)"

public GameObject text;
Color colorText = text.GetComponent<Color>();</blockquote>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Kuzmenko, 2021-08-07
@Gregory256

add library "using TMPro;" and instead of gameobject write TextMeshPro
and then write text.color = Color.and the desired color;

public TextMeshPro text;
text.color = Color.yellow;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question