private void AreYouSureMenu() { string labelText = "Are you sure you want to "; switch (m_pausedMenuState) { case PausedMenuState.MainMenu: labelText += "return to the main menu?"; break; case PausedMenuState.Quit: labelText += "quit the game?"; break; case PausedMenuState.Restart: labelText += "restart the current level?"; break; } ; const float BUTTON_WIDTH = 256; float yPosition = 100; Vector2 textDimensions = GUI.skin.label.CalcSize(new GUIContent(labelText)); Rect labelRect = new Rect((Screen.width * 0.5f) - (textDimensions.x * 0.5f), yPosition, textDimensions.x, textDimensions.y); GUI.Label(labelRect, labelText); yPosition += 96; Rect yesRect = new Rect((Screen.width * 0.5f) - (BUTTON_WIDTH * 0.5f) - 5, yPosition, BUTTON_WIDTH * 0.5f, 32); if (GUI.Button(yesRect, "Yes")) { if (m_pausedMenuState == PausedMenuState.Quit) { Application.Quit(); } else if (m_pausedMenuState == PausedMenuState.MainMenu) { Time.timeScale = 1.0f; Application.LoadLevel("Main_Menu"); } else if (m_pausedMenuState == PausedMenuState.Restart) { CCheckPoint cp = m_playerEntity.LastCheckPoint; CCheckPoint startCp = cp; while (cp.IsLevelStart == false) { cp = cp.NextCheckPoint; if (cp == startCp) { Debug.LogError("No check points in list where marked as level start"); return; } } m_playerEntity.LastCheckPoint = cp; m_playerEntity.OnDeath(); m_pausedMenuState = PausedMenuState.Main; Time.timeScale = 1.0f; m_playerEntity.CurrentGameState = GameState.Running; } return; } Rect noRect = new Rect((Screen.width * 0.5f) + 5, yPosition, BUTTON_WIDTH * 0.5f, 32); if (GUI.Button(noRect, "No")) { m_pausedMenuState = PausedMenuState.Main; return; } }