Hi guys,
I made a script which activate/deactivates a Gameobject. The script itself is working fine, but I need to press ESC twice at the first time. After the gameobject is disabled once, I just need to press one time ESC. Is there a way that i need to press ESC just one time in the beginning?
public class EnableCanHolder : MonoBehaviour {
public GameObject CanHolder;
int CanHolderVisible = 1;
// Use this for initialization
void Start () {
}
// Update is called once per frame
public void Update () {
if (Input.GetKeyDown(KeyCode.Escape) && CanHolderVisible == 1)
{
CanHolder.SetActive(true);
CanHolderVisible = 2;
}
else if (Input.GetKeyDown(KeyCode.Escape) && CanHolderVisible == 2)
{
CanHolder.SetActive(false);
CanHolderVisible = 1;
}
}
}