Unity Scenemanagement Does Not Exist in the Current Context

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);
    }
}

1 Answer

It should be:

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

David Miller

David Miller

Executive Financial & Market Analyst

David Miller brings 15 years of experience in global economics, personal finance strategy, and market dynamics. He specializes in turning complex economic trends into actionable insights for everyday readers.

Share this article
Twitter Facebook Pinterest