Why do we drag Text to the Text field in the Text Controller component? Isn’t the Text that we are dragging just the GameObject that owns Text Controller? If so, why can’t we, say, call it using this
or gameObject
in the script? Wouldn’t that refer to the GameObject Text (which appears to own this instance of the Text Controller)?
Because the Text component can’t be accessed by just “this” or “gameObject”, you have to make it clear which instance of text you are adressing, so the teacher makes the text variable public in order to assign it using the inspector (that is why you have to drag it afterwards).
Another option would be to set the reference to it manually by doing like this:
Text text;
void Start()
{
text = gameObject.GetComponent<Text>();
}