Question by
$$anonymous$$ · Feb 24, 2016 at 02:49 AM ·
unity 5gui3d
How to make Text in canvas disappear on keypress?
So, what I am doing is makeing a game where the controls are printed on-screen as soon as the game starts. I want to have it when the player presses 'Q' the text goes away. How can I do that? I have tried using a toggle componet on the text but I cannot find a keypress button. Please help!
-Devyn (Devix167)
Comment
Answer by $$anonymous$$ · Feb 24, 2016 at 02:50 AM
note: this is my first post and i accidentaly put collision in the tags or whatever they are called
Answer by Pratap-Dafedar · Feb 25, 2016 at 07:06 AM
Try this in update method.
public UnityEngine.UI.Text textLabel;
Update ()
{
if (Input.GetKeyDown("A"))
{
//button got pressed.
//hide your text here.
textLabel.text = ""; //or textLabel.gameobject.SetActive (false);
}
}
Your answer
Follow this Question
Related Questions
Cant keep OnGUI() elements to the same position C# 1 Answer
I am doing a runner game, i need to detect a down swipe on the screen 0 Answers
Cube is shaking. 0 Answers
How do i create sub meshes? 1 Answer