How would you use a keystroke to make a GUI.Box visible or invisible. This is what I have now.
void OnGUI() {
GUI.Label(new Rect(screenPosition.x - 36, screenPosition.y - 35, Screen.width / 8, 7), “Health”);
GUI.Box(new Rect(screenPosition.x - 36, screenPosition.y - 35, healthBarLength, 7), “Health”);
if(Input.GetKeyUp(KeyCode.U))
{
GUI.enabled = false;
}
}
the GUI.enabled = false does not do anything though
mgear
2
appels
3
boolean showWindows = false;
void OnGUI() {
if(showWindows)
GUI.Label(new Rect(screenPosition.x - 36, screenPosition.y - 35, Screen.width / 8, 7), "Health");
GUI.Box(new Rect(screenPosition.x - 36, screenPosition.y - 35, healthBarLength, 7), "Health");
}
}
void FixedUpdate() {
if(Input.GetKeyUp(KeyCode.U))
{
if(showWindows)
showWindows = false;
else
showWindows = true;
}
}