Question by
ms06962222 · May 11, 2020 at 08:42 PM ·
bugenemyproblem during runtime
How to fix pause menu problem?
Hello, I am having a problem with my C# pause menu script. What happens is when "escape" is pressed to open the menu it's fine and when you press it to close it close fine also. But the problem is when I press "escape" the game doesn't pause completely it paused but I can move the player hand with the gun and the boxes that are flying after shooting on them they paused and also can't press the buttons. Can anyone help me? thanks in advance. Here's my script:
using UnityEngine;
using UnityEngine.SceneManagement;
public class PauseMenu : MonoBehaviour
{
#region Variables
public static bool GameIsPaused = false;
public GameObject pauseMenuUI;
#endregion
#region
private void Update()
{
Debug.Log("!");
if(Input.GetKeyDown(KeyCode.Escape))
{
if(GameIsPaused)
{
Resume();
}
else
{
Pause();
}
}
}
public void Resume()
{
pauseMenuUI.SetActive(false);
Time.timeScale = 1f;
GameIsPaused = false;
}
public void Pause()
{
pauseMenuUI.SetActive(true);
Time.timeScale = 0f;
GameIsPaused = true;
}
public void LoadMenu()
{
Time.timeScale = 1f;
SceneManager.LoadScene(0);
}
public void QuitGame()
{
Debug.Log("You are quiting the game ");
Application.Quit();
}
#endregion
}
Comment
Your answer
Follow this Question
Related Questions
Problem with textures 0 Answers
Graphic bug only in the build,Graphic problem only in the build 0 Answers
Problems opening the editor 0 Answers
Prefabs executing in a wrong way. 0 Answers