- Home /
Question by
matthew798 · Feb 05, 2014 at 03:17 AM ·
booleantoggleboolkeygetkeydown
Toggle bool with keypress
When i press escape, nothing happens...
#pragma strict
var windowTexture : Texture;
var viewScreenBorderTexture : Texture;
var shipMenu : int = 0;
var pauseMenu : boolean = false;
function Start () {
}
function Update () {
if(Input.GetKeyDown(KeyCode.Escape)){
pauseMenu = !pauseMenu;
}
}
function OnGUI () {
if(pauseMenu == true){
GUI.DrawTexture(Rect(50,50,6,300), windowTexture);
}
}
The variable pauseMenu is not changing in the inspector. But if i click it on and off manually (again, in the inspector), my menu appears and disappears as it should.
I suspect that GetKeyDown is the culprit... Thanks!
Comment
I've looked at this 2 or 3 times now and don't see a problem.
After your input.getkeydown insert
debug.log("pause$$anonymous$$enu gettin flipped");
or whatever
Your answer
Follow this Question
Related Questions
Boolean and input relation 0 Answers
How to change function of a key with a boolean 1 Answer
Press key to toggle pointlight on/off 1 Answer