mirror of
https://github.com/Fluffy-Bean/Again.git
synced 2025-05-14 13:12:16 +00:00
Added pause menu script
This commit is contained in:
parent
ed68280480
commit
90ce1284c1
2 changed files with 42 additions and 0 deletions
41
PauseMenu.cs
Normal file
41
PauseMenu.cs
Normal file
|
@ -0,0 +1,41 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class PauseMenu : MonoBehaviour
|
||||
{
|
||||
|
||||
public static bool GameIsPaused = false;
|
||||
|
||||
public GameObject pauseMenuUI;
|
||||
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.Escape))
|
||||
{
|
||||
if (GameIsPaused == true)
|
||||
{
|
||||
Resume();
|
||||
} else
|
||||
{
|
||||
Pause();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Resume ()
|
||||
{
|
||||
pauseMenuUI.SetActive(false);
|
||||
Time.timeScale = 1f;
|
||||
GameIsPaused = false;
|
||||
Cursor.lockState = CursorLockMode.Locked;
|
||||
}
|
||||
void Pause ()
|
||||
{
|
||||
pauseMenuUI.SetActive(true);
|
||||
Time.timeScale = 0f;
|
||||
GameIsPaused = true;
|
||||
Cursor.lockState = CursorLockMode.None;
|
||||
}
|
||||
}
|
|
@ -12,5 +12,6 @@ public class levelLoader : MonoBehaviour
|
|||
PlayerPrefs.SetFloat("lowestTime",9999f);
|
||||
}
|
||||
SceneManager.LoadScene("game");
|
||||
Time.timeScale = 1f;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue