# Unity access Label in GUI?

There is a quick and dirty appreoch to creating text boxes:

void OnGUI(){
GUILayout.Label("Text 1");
}


It works well. But, since the Label method returns void, how do I access this later on?

Let's say I want to access the text later to change the score?

someField = GUILayout.Label("Text 1");


Is not going to work.

## 1 Answer

With a Label, the only way would be to keep your text in a string variable and manually handle all key events by changing the string variable accordingly. Clearly, this is far from ideal.

If you want a quick and dirty textbox, you should use TextField, which does all of the hard work for you.

Of course, this assumes you're sticking with the classic UI system, which your code snippet suggests. If you're using the new UI system, add an Input Field to a Text control.