Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class PauseMenu : MonoBehaviour
{
// Start is called before the first frame update
public static bool PauseGame = false;
public GameObject pauseMenu;
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown(KeyCode.Escape)) //checks if you hit escape
{
if (PauseGame)
{
Resume(); //if pause game was true, then it resumes the game
}
else
{
Pause(); //if it wasn't, then the game will be paused
}
}
}
void Resume()
{
pauseMenu.SetActive(false);//sets the pause menu in the canvas to false
Time.timeScale = 1f; //un-freezes the scene
PauseGame = false;
}
void Pause()
{
pauseMenu.SetActive(true); //sets the pause menu in the canvas to true
Time.timeScale = 0f; //freezes the scene
PauseGame = true;
}
}