Is there a way (I’m sure there is), to display a GameObject (or UI) when the user hits a specific key? (Like displaying, and then hiding a pop-up of instructions during gameplay)
How would I go about doing that?
Much appreciated.
Is there a way (I’m sure there is), to display a GameObject (or UI) when the user hits a specific key? (Like displaying, and then hiding a pop-up of instructions during gameplay)
How would I go about doing that?
Much appreciated.
Take a look on both threads:
I hope help you.
Alexandre ![]()
I mean more along the lines of - I want a UI element to be set to active when a keyboard key is hit, and then deactivated when the key is hit again.
Use this stuff: Unity - Scripting API: Input
Create a reference to the UI you’re turning on and off and drag it in in the editor.
public Canvas onoffCanvas;
bool CanvasIsOn = true;
void Update()
{
if (Input.GetKeyDown("key"))
{
if (CanvasIsOn == true)
{
CanvasIsOn = false;
onoffCanvas.enabled = CanvasIsOn;
}
else
{
CanvasIsOn = true;
onoffCanvas.enabled = CanvasIsOn
}
}
}
Doesn’t need to be a canvas it can be just like whatever.
Worked perfectly, thank you!