- Home /
Runtime writing text.
I have a button. I want, when I press the button, for a text appear somewhere in the screen. How do I do it?
To be more specific, I want to do while runtime standalone, what printing on Console does. If I don't have the console while running I can't see my variables.
Answer by gardian06 · Feb 28, 2013 at 05:43 PM
you can do this one of multiple ways you can either create a sudo-console similar to what you see in many PC games (by pressing '`'), or you can simply create labels to display to the screen.
since anything written inside of OnGUI()
will be super imposed over the current screen render (the scene world) you can have this impose labels on the screen that will always be in the foreground.
// simple GUI.Label
GUI.Label(new Rect(0,0,200, 20), "pos.x: " + transform.position.x);
as for the sudo-console that will take a fair bit more work that I don't think you will need based on your question.
Your answer
![](https://koobas.hobune.stream/wayback/20220613064744im_/https://answers.unity.com/themes/thub/images/avi.jpg)