56 lines
923 B
C#
56 lines
923 B
C#
using UnityEngine;
|
|
using UnityEngine.SceneManagement;
|
|
|
|
public class PauseMenu : MonoBehaviour
|
|
{
|
|
|
|
public GameObject pauseMenuUI;
|
|
|
|
public DontDestroy notDestroyedObjects;
|
|
|
|
public static bool gameIsPaused = false;
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
if (Input.GetKeyDown(KeyCode.Escape))
|
|
{
|
|
if (gameIsPaused)
|
|
{
|
|
Resume();
|
|
}
|
|
else
|
|
{
|
|
Paused();
|
|
}
|
|
}
|
|
}
|
|
|
|
void Paused()
|
|
{
|
|
pauseMenuUI.SetActive(true);
|
|
|
|
Time.timeScale = 0;
|
|
|
|
gameIsPaused = true;
|
|
}
|
|
|
|
public void Resume()
|
|
{
|
|
pauseMenuUI.SetActive(false);
|
|
|
|
Time.timeScale = 1;
|
|
|
|
gameIsPaused = false;
|
|
}
|
|
|
|
public void LoadMainMenu()
|
|
{
|
|
SceneManager.LoadScene("MainMenu");
|
|
}
|
|
|
|
public void Settings()
|
|
{
|
|
|
|
}
|
|
}
|