I'd like to display a GUI text at run time in my game for a second, so I want to know if it's possible to add or remove a GUI label to the scene at run time?
2 Answers
\$\begingroup\$
\$\endgroup\$
- start a coroutine, which first waits for 1 second, and then set a boolean member variable to true (which initially is false)
- in OnGUI => if the bool is true show the Label
\$\begingroup\$
\$\endgroup\$
2
Is this what you mean?
void OnGUI() {
GUI.Label(new Rect(10f, 10f, 100f, 50f), "YourText");
}
Or, in UnityScript (basically the same):
function OnGUI() {
GUI.Label(new Rect(10f, 10f, 100f, 50f), "YourText");
}
-
\$\begingroup\$ :no I want this to be happened at a specific time at run time \$\endgroup\$– AkariCommented Oct 21, 2013 at 12:20
-
1\$\begingroup\$ @Akari Then you might want to check
realTimeSinceStartup
to determine whether it should show the text. \$\endgroup\$– LokkijCommented Oct 21, 2013 at 12:29