unity scripting ui text part 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: how to set a color of text in unity 2020 script
TextVar = TextGameObject.color = Color.red;