Hi I'm working on a game for a school project but I'm still pretty new at game dev, I decided to add a pause menu to my game but for some reason, it only works in one of the scenes in unity, and I can't tell why it won't work on any of the other ones
Here is a video showing the problem: https://youtu.be/28fD9UEtfpg
and here is my script just in case
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PauseMenu : MonoBehaviour
{
public static bool GameIsPaused = false;
public GameObject PauseMenuUI;
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown(KeyCode.Escape))
{
if (GameIsPaused)
{
Resume();
}
else
{
Pause();
}
}
}
public void Resume()
{
PauseMenuUI.SetActive(false);
Time.timeScale = 1f;
GameIsPaused = false;
Cursor.lockState = CursorLockMode.Locked;
Cursor.visible = false;
}
void Pause()
{
PauseMenuUI.SetActive(true);
Time.timeScale = 0f;
GameIsPaused = true;
Cursor.lockState = CursorLockMode.None;
Cursor.visible = true;
}
}