how to add show-hide just one key?

var render : boolean=false;
function OnGUI ()
{
if(Input.GetKeyDown(KeyCode.E))
{
if(!render)
{
Debug.Log(“open”);
render=true;
}
}
if(Input.GetKeyDown(KeyCode.E))
{
if(render)
{
Debug.Log(“close”);
render=false;
}
}
}

i want when i will press key E then gui box is show or hide(if showing gui box and press E then close the gui box). i have tried Input.GetKey , Input.GetKeyUp and different if codes type . in this codes when i press key E than guibox is open but close without i dont see the gui box .how can i do this?

sorry if you dont like my english :slight_smile:

OnGUI can be called multiple times per frame. Put your key event handling code in Update().

var render : boolean=false;
function Update()
{
    if(Input.GetKeyDown(KeyCode.E))
        render = !render;
}

function OnGUI()
{
    if (render)
    {
        //do it
    }
}

This is simple follow the below code

    var render : boolean=false;
    function OnGUI () 
    {       
            if(Input.GetKeyDown(KeyCode.E))
             {
                  renderer = !renderer;
             }
     }