unity text component script code example
Example 1: get text component unity
GameObject.GetComponent<Text>().text = "Hello World!";
Example 2: how to access a text gameobjceet in unity and change it
Text text = gameObj.GetComponentInChildren(typeof(Text)) as Text;
text.text = "text stuff";
text.font = prefferedFont;