JamieLeveridge f3ef2d4c94 Added Pause Script + UI
(UI script set up confusingly so I was forced to make it a seperate script)
2021-11-07 16:21:56 +00:00

44 lines
826 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PauseMenu : MonoBehaviour
{
public GameObject pausePanel;
private bool paused = false;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown(KeyCode.Escape))
{
if(paused == true)
{
unpauseGame();
}
else
{
pauseGame();
}
}
}
void pauseGame()
{
paused = true;
pausePanel.SetActive(true);
Time.timeScale = 0;
}
void unpauseGame()
{
paused = false;
pausePanel.SetActive(false);
Time.timeScale = 1;
}
}