51 lines
1.3 KiB
C#
51 lines
1.3 KiB
C#
using JTN;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class PausePanel : MonoBehaviour
|
|
{
|
|
public GameObject PauseMenuPanel;
|
|
public GameObject PauseButton;
|
|
public KeyCode PauseKey = KeyCode.Escape;
|
|
public bool Paused;
|
|
public FirstPersonController PlayerController;
|
|
|
|
void Update()
|
|
{
|
|
if (PauseMenuPanel && PauseButton)
|
|
{
|
|
if (Input.GetKeyDown(PauseKey))
|
|
{
|
|
Debug.Log("Paused with " + PauseKey.ToString());
|
|
Pause();
|
|
}
|
|
}
|
|
}
|
|
|
|
public void Pause()
|
|
{
|
|
Debug.Log("Pause state: " + Paused);
|
|
if (!Paused)
|
|
{
|
|
PlayerController.enabled = false;
|
|
PauseButton.SetActive(false);
|
|
PauseMenuPanel.SetActive(true);
|
|
|
|
Paused = true;
|
|
Cursor.lockState = CursorLockMode.None;
|
|
Time.timeScale = 0;
|
|
}
|
|
else
|
|
{
|
|
PlayerController.enabled = true;
|
|
PauseButton.SetActive(true);
|
|
PauseMenuPanel.SetActive(false);
|
|
|
|
Paused = false;
|
|
Cursor.lockState = CursorLockMode.Locked;
|
|
Time.timeScale = 1;
|
|
}
|
|
}
|
|
}
|