- Home /
Disable component via script
I have have a title (in form of gui text) at the start of the game, and I want it to disappear when anykey is pressed. The optimal thing to do would be to fade it out, how do you do that? Or at least, how do you disable the component via script?
Comment
Best Answer
Answer by Em3rgency · Jul 04, 2013 at 01:31 PM
http://docs.unity3d.com/Documentation/ScriptReference/Behaviour-enabled.html
Thats if you want to disable the script all together. But if you want to just stop drawing something when any key is pressed, a simple bool can help you.
private bool somethingPressed = false;
void update()
{
if(Input.anyKey)
somethingpressed = true;
}
void onGUI()
{
if(!somethingPressed)
{
//draw your title here or whatever
}
}
Your answer
Follow this Question
Related Questions
fade in out multi images then go to next scene 1 Answer
Appear after set number of seconds 2 Answers
Fade In GUI on proximity 1 Answer
Transitions When Pausing? 1 Answer
Time Since Event? 1 Answer