show gui label on key press

I have a gui label with an image that i want to display when a value is true and the key M has been pressed, but nothing is displaying with this code

var map : Texture2D;
function OnGUI () {
if (hud){

	if(Input.GetKeyDown("m")){

	GUI.Label (Rect (400, 40, map.width, map.height),map);

    }

}
}

You don’t appear to be defining ‘hud’ as a boolean? Is there a bit of the script missing because right now, ‘hud’ is never being defined and so can’t be true, and therefore of course, it’s not allowing you to bring up you’re GUI label.

To define ‘hud’ try:

var hud : boolean = true;

Hope that helps, Klep

You should call Input.GetKeyDown in update and use it to set a boolean. Then in onGUI check for hud and this new boolean