Today we will see how to access / edit the "Text" of a GameObject, using only C #, without using the Inspector.


Name of the GameObject:

Goal: modify the text.

1 - Very simple, we declare the variable at the beginning (text1)

2 - Now we will use the second line to search, through its name, the Gameobject.
we assign
"Text" property to our "text1" variable (we can use any other that it has).

3 - In the third line, we modify the value and it will be automatically reflected in our program.



     public Text text1;  // 1


       text1 = GameObject.Find("title_one").GetComponent<Text>(); // 2

       texto.text = "Opciones";  // 3

website counter