unity change text color code example
Example 1: unity change text color
// To change the color of a text, see below
GameObject.GetComponent<Text>().color = Color.black;
Example 2: unity change text
// To change text of a text UI element use th combination below
textGameObject.GetComponent<UnityEngine.UI.Text>().text = "text";
Example 3: how to set a color of text in unity 2020 script
TextVar = TextGameObject.color = Color.red;