unity change ui text from script 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 how to change text in script
Text myText = GameObject.Find("Canvas/Text").GetComponent<Text>();
myText.text = "Your text changed!";