0
\$\begingroup\$

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?

\$\endgroup\$
1
  • \$\begingroup\$ Sure you can do that. What have you tried so far? \$\endgroup\$
    – bummzack
    Commented Oct 21, 2013 at 8:02

2 Answers 2

1
\$\begingroup\$
  • 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
\$\endgroup\$
2
\$\begingroup\$

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");
}
\$\endgroup\$
2
  • \$\begingroup\$ :no I want this to be happened at a specific time at run time \$\endgroup\$
    – Akari
    Commented 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\$
    – Lokkij
    Commented Oct 21, 2013 at 12:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .