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

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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.

You Might Also Like