81 lines
1.7 KiB
C#
81 lines
1.7 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.SceneManagement;
|
|
|
|
public class PauseMenu : MonoBehaviour
|
|
{
|
|
|
|
public static bool GameIsPaused = false;
|
|
|
|
public GameObject pauseMenuUI;
|
|
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
|
|
if(Input.GetButtonDown("Pause"))
|
|
{
|
|
if(GameIsPaused)
|
|
{
|
|
Resume();
|
|
Cursor.visible = !Cursor.visible;
|
|
Cursor.lockState = CursorLockMode.Locked;
|
|
} else {
|
|
Pause();
|
|
Cursor.visible = Cursor.visible;
|
|
Cursor.lockState = CursorLockMode.None;
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
public void Resume()
|
|
{
|
|
pauseMenuUI.SetActive(false);
|
|
Time.timeScale = 1f;
|
|
GameIsPaused = false;
|
|
Cursor.visible = !Cursor.visible;
|
|
Cursor.lockState = CursorLockMode.Locked;
|
|
}
|
|
|
|
void Pause()
|
|
{
|
|
pauseMenuUI.SetActive(true);
|
|
Time.timeScale = 0f;
|
|
GameIsPaused = true;
|
|
Cursor.visible = Cursor.visible;
|
|
Cursor.lockState = CursorLockMode.None;
|
|
}
|
|
|
|
public void LoadHubWorld()
|
|
{
|
|
Time.timeScale = 1f;
|
|
GameIsPaused = false;
|
|
SceneManager.LoadScene("Hub World", LoadSceneMode.Single);
|
|
Cursor.visible = !Cursor.visible;
|
|
Cursor.lockState = CursorLockMode.Locked;
|
|
}
|
|
|
|
public void LoadMenu()
|
|
{
|
|
Time.timeScale = 1f;
|
|
GameIsPaused = false;
|
|
SceneManager.LoadScene("Main Menu", LoadSceneMode.Single);
|
|
}
|
|
|
|
public void Quit()
|
|
{
|
|
|
|
Application.Quit();
|
|
Debug.Log("QUIT");
|
|
|
|
}
|
|
}
|