void Update() { bool EscapePressed = Input.GetButton("Escape"); //Check if escape is pressed down if (EscapePressed && !PreviousEscapeStatus) { //If we don't have anything selected if (inputControllerScript.GetSelectedObject() == null) { //Open menu MenuScript menuScript = (MenuScript)MenusObject.GetComponent(typeof(MenuScript)); menuScript.EscapePressed(); } else { //Clear our selection inputControllerScript.SetSelectedObject(null); } } PreviousEscapeStatus = EscapePressed; }