All checks were successful
Build project / Build for (StandaloneLinux64, 6000.0.37f1) (push) Successful in 5m20s
Build project / Build for (StandaloneWindows64, 6000.0.37f1) (push) Successful in 5m3s
Build project / Publish to itch.io (StandaloneLinux64) (push) Successful in 4s
Build project / Publish to itch.io (StandaloneWindows64) (push) Successful in 5s
72 lines
1.6 KiB
C#
72 lines
1.6 KiB
C#
using UnityEngine;
|
|
using UnityEngine.SceneManagement;
|
|
|
|
public class PauseMenu : MonoBehaviour
|
|
{
|
|
public GameObject pauseMenuUI;
|
|
public GameObject[] crosshairs;
|
|
public MonoBehaviour playerMovementScript;
|
|
|
|
private bool isPaused = false;
|
|
|
|
void Start()
|
|
{
|
|
pauseMenuUI.SetActive(false);
|
|
}
|
|
|
|
void Update()
|
|
{
|
|
if (Input.GetKeyDown(KeyCode.Escape))
|
|
{
|
|
if (isPaused)
|
|
Resume();
|
|
else
|
|
Pause();
|
|
}
|
|
}
|
|
|
|
public void Resume()
|
|
{
|
|
pauseMenuUI.SetActive(false);
|
|
foreach (GameObject crosshair in crosshairs)
|
|
{
|
|
if (crosshair != null)
|
|
crosshair.SetActive(true);
|
|
}
|
|
if (playerMovementScript != null)
|
|
playerMovementScript.enabled = true;
|
|
Time.timeScale = 1f;
|
|
isPaused = false;
|
|
Cursor.lockState = CursorLockMode.Locked;
|
|
Cursor.visible = false;
|
|
}
|
|
|
|
void Pause()
|
|
{
|
|
pauseMenuUI.SetActive(true);
|
|
foreach (GameObject crosshair in crosshairs)
|
|
{
|
|
if (crosshair != null)
|
|
crosshair.SetActive(false);
|
|
}
|
|
if (playerMovementScript != null)
|
|
playerMovementScript.enabled = false;
|
|
Time.timeScale = 0f;
|
|
isPaused = true;
|
|
Cursor.lockState = CursorLockMode.None;
|
|
Cursor.visible = true;
|
|
}
|
|
|
|
public void ReturnToMainMenu()
|
|
{
|
|
Time.timeScale = 1f;
|
|
SceneManager.LoadScene("MainMenu");
|
|
}
|
|
|
|
public void ExitGame()
|
|
{
|
|
Debug.Log("Exiting game...");
|
|
Application.Quit();
|
|
}
|
|
}
|