- Home /
Pause Menu not working
I was following a Brackey tutorial for a simple Pause Menu. The problem is that even though I have implemented the code as said in the video, it would not appear and would crash my project. Any solutions? P.S this is the video:https://www.youtube.com/watch?v=JivuXdrIHK0 and this is the code:
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using UnityEngine.SceneManagement;
public class PauseMenu : MonoBehaviour {
public static bool GameIsPaused = false;
public GameObject pauseMenuUI;
void Update()
{
if (Input.GetKeyDown(KeyCode.Escape))
{
if (GameIsPaused)
{
Debug.Log("game is paused");
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 LoadMenu()
{
Time.timeScale = 1f;
SceneManager.LoadScene("Main Menu");
}
// Quit game exits the game
public void QuitGame()
{
Debug.Log("Quitting game...");
Application.Quit();
}
}
Your code seems fine, if your whole project is crashing is probably due to something else in it, hard to know what in especific without looking at the project itself.
Your answer
![](https://koobas.hobune.stream/wayback/20220613060513im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Struggling with my pause menu and main menu 1 Answer
GUI Buttons not working after scene transition 0 Answers
How to make a menu? 1 Answer
Pause Menu open/close on key 1 Answer
Pause menu not working 1 Answer