Permalink
Cannot retrieve contributors at this time
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?
DMD2542-Project4-AndrewSides/Final Platformer/Assets/Scripts/PauseMenu.cs
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
42 lines (37 sloc)
1.04 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} | |
} |