void Update() { if (Input.GetKeyDown(KeyCode.Escape)) { if (CurrentPopup) { CurrentPopup.EscapePressed(); } else if (CurrentMenu) { CurrentMenu.EscapePressed(); } } }