|
|
@@ -0,0 +1,59 @@
|
|
|
+using UnityEngine;
|
|
|
+using UnityEngine.SceneManagement;
|
|
|
+
|
|
|
+public class PauseMenu : MonoBehaviour
|
|
|
+{
|
|
|
+ public GameObject pauseMenuUI;
|
|
|
+ public string mainMenu = "MainMenu";
|
|
|
+
|
|
|
+ private bool isPaused = false;
|
|
|
+
|
|
|
+ void Update()
|
|
|
+ {
|
|
|
+ if (Input.GetKeyDown(KeyCode.Escape)) {
|
|
|
+ if (!isPaused)
|
|
|
+ {
|
|
|
+ PauseGame();
|
|
|
+ } else
|
|
|
+ {
|
|
|
+ ResumeGame();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public void PauseGame()
|
|
|
+ {
|
|
|
+ pauseMenuUI.SetActive(true);
|
|
|
+ Time.timeScale = 0f;
|
|
|
+ isPaused = true;
|
|
|
+
|
|
|
+ Cursor.lockState = CursorLockMode.None;
|
|
|
+ Cursor.visible = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void ResumeGame()
|
|
|
+ {
|
|
|
+ pauseMenuUI.SetActive(false);
|
|
|
+ Time.timeScale = 1f;
|
|
|
+ isPaused = false;
|
|
|
+
|
|
|
+ Cursor.lockState = CursorLockMode.Locked;
|
|
|
+ Cursor.visible = false;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void SaveGame()
|
|
|
+ {
|
|
|
+ Debug.Log("Save");
|
|
|
+ }
|
|
|
+
|
|
|
+ public void LoadGame()
|
|
|
+ {
|
|
|
+ Debug.Log("Load");
|
|
|
+ }
|
|
|
+
|
|
|
+ public void ReturnToMainMenu()
|
|
|
+ {
|
|
|
+ Time.timeScale = 1f;
|
|
|
+ SceneManager.LoadScene(mainMenu);
|
|
|
+ }
|
|
|
+}
|