Skip to content

Instantly share code, notes, and snippets.

@saturngamesss
Created April 22, 2020 16:21
Show Gist options
  • Save saturngamesss/50eeba90c5f875f4995f1d384fe21c8b to your computer and use it in GitHub Desktop.
Save saturngamesss/50eeba90c5f875f4995f1d384fe21c8b to your computer and use it in GitHub Desktop.
Basic pause menu code for Unity.
//************** REAL GAMES STUDIO ***************
//************************************************
//realgamesss.weebly.com
//gamejolt.com/@Real_Game
//realgamesss.newgrounds.com/
//real-games.itch.io/
//youtube.com/channel/UC_Adg-mo-IPg6uLacuQCZCQ
//************************************************
using UnityEngine;
public class PauseMenu : MonoBehaviour {
public static bool GameIsPaused = false;
public GameObject pauseMenuUI;
void Update () {
if (Input.GetKeyDown (KeyCode.Escape))
{
if (GameIsPaused)
{
Resume();
} else
{
Pause();
}
}
}
public void Resume ()
{
pauseMenuUI.SetActive (false);
Time.timeScale = 1f;
GameIsPaused = false;
}
void Pause ()
{
pauseMenuUI.SetActive (true);
Time.timeScale = 0f;
GameIsPaused = true;
}
public void QuitGame()
{
Debug.Log ("Quiting game...");
Application.Quit ();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment