- Home /
Destroying GUI.Label after X seconds
Hi. I need help with one thing, that i can't make. Can anyone explain me how to destroy GUI.Label after X seconds? And maybe how to add fade out transition (if possible). Please write the code in C#, because i;m understanding it faster than JS ;)
Answer by Eric5h5 · Nov 06, 2012 at 02:11 AM
GUI code is immediate mode, so GUI.Label only exists for one frame, therefore it's not something you ever destroy. Rather you can just stop using it after X seconds in your OnGUI function, using some kind of timer (using Invoke would be a simple way). You can use a boolean ("if (showLabel) GUI.Label(...)"), or for best performance disable the script, that way the OnGUI function will stop running entirely.
Answer by thedodgeruk · Nov 05, 2012 at 11:56 PM
public GUI.Label m_temp; public float m_seconds = 5;
void Start() { destroy ( m_temp, m_seconds ); }
Your answer
Follow this Question
Related Questions
Making a text box appear after a certain gameObject is destroyed 0 Answers
GUIStyle returning error (error inside) 1 Answer
How Do I Center A GUI Label? 5 Answers
GUI.Label positioning for many device resolutions 1 Answer
network GUI not working 1 Answer