i am trying to make a platformer and i need help to switch between Scenes/Levels but when i switch back to level 2 from level one y game freezes and you open the level selector by pressing escape or dying,I am trying to make a Platformer in unity and i need to switch between scenes/levels but when i switch back to level 2 and try to switch to another level the game freezes,i am making a platformer and am trying to switch between scenes/ levels but once i switch back to level 2 and try to switch to a new level the game freezes
Code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
public class GameManager : MonoBehaviour
{
public PlayerController pc;
public GameObject gameOverMenu;
// Start is called before the first frame update
void Start()
{
gameOverMenu.SetActive(false);
}
// Update is called once per frame
void Update()
{
if (pc.isDead == true)
{
gameOverMenu.SetActive(true);
}
}
public void Redo()
{
Debug.Log("Button was pressed!");
RestartGame();
}
void RestartGame()
{
SceneManager.LoadScene(SceneManager.GetActiveScene().name);
}
public void Quit()
{
Application.Quit();
}
public void Lv1()
{
SceneManager.LoadScene("Lv1", LoadSceneMode.Single);
pc.isDead = false;
}
public void Lv2()
{
SceneManager.LoadScene("Lv2", LoadSceneMode.Single);
pc.isDead = false;
}
public void Lv3()
{
SceneManager.LoadScene("Lv3", LoadSceneMode.Single);
pc.isDead = false;
}
public void Lv4()
{
SceneManager.LoadScene("Lv4", LoadSceneMode.Single);
pc.isDead = false;
}
public void Lv5()
{
SceneManager.LoadScene("Lv5", LoadSceneMode.Single);
pc.isDead = false;
}
}