how do i reference to a text objects text in scripting?

c# script

referencing the script to the number within the text object.

This is for an OnMouseDown script.

74187-screen-shot-2016-07-16-at-91416-pm.png

If both text and your script are on the same gameobject,

gameObject.GetComponent<Text>().text = "Your string here, yo!";

If your text and script are different objects, in the script make to sure add a using UnityEngine.UI at the top so that you’ll be able to edit the text.

Then make a public Text textObject. Then from within the editor you can drag the text object onto the slot.

Then you can just use textObject.text = "whatever text you want";

Or you could have the script search for the text object using GameObject.Find().

How you could do this is: Text textObject = GameObject.Find("textObject");. Put it in the Start() function.

More on GameObject.Find() can be found here.