access the text color component unity code example
Example: unity change text color
// To change the color of a text, see below
GameObject.GetComponent<Text>().color = Color.black;
// To change the color of a text, see below
GameObject.GetComponent<Text>().color = Color.black;