Init repository
This commit is contained in:
Executable file
+50
@@ -0,0 +1,50 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user