82 lines
1.9 KiB
C#
82 lines
1.9 KiB
C#
using Cinemachine;
|
|
using UnityEngine;
|
|
using UnityEngine.SceneManagement;
|
|
|
|
public class PauseMenuManager : MonoBehaviour
|
|
{
|
|
[SerializeField] private GameObject pauseMenuCanvas;
|
|
[SerializeField] private CinemachineFreeLook freeLookCamera;
|
|
|
|
private bool isPaused;
|
|
|
|
void Start()
|
|
{
|
|
if (freeLookCamera != null)
|
|
{
|
|
freeLookCamera.m_XAxis.m_InputAxisName = "Mouse X";
|
|
freeLookCamera.m_YAxis.m_InputAxisName = "Mouse Y";
|
|
}
|
|
|
|
pauseMenuCanvas.SetActive(false);
|
|
Time.timeScale = 1f;
|
|
}
|
|
|
|
//void Update()
|
|
//{
|
|
// if (Input.GetKeyDown(KeyCode.Escape))
|
|
// {
|
|
// if (isPaused)
|
|
// ResumeGame();
|
|
// else
|
|
// PauseGame();
|
|
// }
|
|
//}
|
|
|
|
public void PauseGame()
|
|
{
|
|
pauseMenuCanvas.SetActive(true);
|
|
Time.timeScale = 0f;
|
|
isPaused = true;
|
|
|
|
//Cursor.lockState = CursorLockMode.None;
|
|
//Cursor.visible = true;
|
|
|
|
if (freeLookCamera != null)
|
|
{
|
|
freeLookCamera.m_XAxis.m_InputAxisName = "";
|
|
freeLookCamera.m_YAxis.m_InputAxisName = "";
|
|
}
|
|
}
|
|
|
|
public void ResumeGame()
|
|
{
|
|
pauseMenuCanvas.SetActive(false);
|
|
Time.timeScale = 1f;
|
|
isPaused = false;
|
|
|
|
//Cursor.lockState = CursorLockMode.Locked;
|
|
//Cursor.visible = false;
|
|
|
|
if (freeLookCamera != null)
|
|
{
|
|
freeLookCamera.m_XAxis.m_InputAxisName = "Mouse X";
|
|
freeLookCamera.m_YAxis.m_InputAxisName = "Mouse Y";
|
|
}
|
|
}
|
|
|
|
public void RestartGame()
|
|
{
|
|
Time.timeScale = 1f;
|
|
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
|
|
}
|
|
|
|
public void QuitGame()
|
|
{
|
|
Time.timeScale = 1f;
|
|
Application.Quit();
|
|
|
|
#if UNITY_EDITOR
|
|
UnityEditor.EditorApplication.isPlaying = false;
|
|
#endif
|
|
}
|
|
} |