public void ToggleWarning() { if (canvas.activeSelf) { canvas.SetActive(false); warning = Warning.CreateWarning("Are you sure you want to reset your highscores?"); var yesBtn = Warning.GetYesBtn(warning); var noBtn = Warning.GetNoBtn(warning); noBtn.onClick.AddListener(() => ToggleWarning()); yesBtn.onClick.AddListener(() => ResetScores()); } else { canvas.SetActive(true); Menu.SwitchFocus(resetBtn); } }
void CreateRestartWarning() { if (gameOver) { RestartGame(); return; } currWarning = Warning.CreateWarning("Are you sure you want to restart the game?"); var warning = currWarning.transform; // obtaining button component var yesBtn = Warning.GetYesBtn(currWarning); var noBtn = Warning.GetNoBtn(currWarning); // adding button events yesBtn.onClick.AddListener(() => RestartGame()); noBtn.onClick.AddListener(() => ResumeGame()); }
public void CreateReturnWarning() { if (gameOver) { menu.ChangeScene("Main Menu"); return; } currWarning = Warning.CreateWarning("Are you sure you want to return to main menu?"); var warning = currWarning.transform; // obtaining button component var yesBtn = Warning.GetYesBtn(currWarning); var noBtn = Warning.GetNoBtn(currWarning); // adding button events yesBtn.onClick.AddListener(() => menu.ChangeScene("Main Menu")); noBtn.onClick.AddListener(() => ToggleWarning(false)); }