Home > Software engineering >  Unity SceneManagement does not exist in the current context
Unity SceneManagement does not exist in the current context

Time:10-17

I am relatively new to c# and Unity. I am trying to make a restart button so when the GameOver screen pops up, the button reloads the scene. However I keep getting an error saying that the name 'SceneManagement' does not exist in the current context. I was wondering how I could fix this?

Code:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

public class RestartButtonScript : MonoBehaviour
{
    // ...

    public void restartScene()
    {
        SceneManagement.LoadScene(SceneManager.GetActiveScene().name);
    }
}

CodePudding user response:

It should be:

public void RestartLevel()
{
    SceneManager.LoadScene( SceneManager.GetActiveScene().name );
}
  • Related