Question by
lucatonigr2016 · Oct 21, 2020 at 08:20 PM ·
strange ioc
How do i open PauseMenu with ESC?
I have the following code and my PauseMenu is not popping out: using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.SceneManagement;
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 LoadMenu()
{
Time.timeScale = 1f;
SceneManager.LoadScene("Menu");
}
public void QuitGame()
{
Debug.Log("Quitting game...");
Application.Quit();
}
}
Comment