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
}
↧