How do I fix obselete reference for space shooter tutorial on c#?

I followed the “how to move the player” video for the Space Shooter tutorial to the end but I’m getting this error on Unity 5.

Assets/Done/Done_Scripts/Done_GameController.cs(38,57): warning CS0618: UnityEngine.Application.LoadLevel(int)' is obsolete: Use SceneManager.LoadScene’

How do I fix this?

Hello, @sanc00.

The error is caused by using the outdated function, Application.LoadLevel to load a scene. We now use, SceneManager.LoadScene. To resolve this issue, please apply these steps in the script, Done_GameController.cs:

(1) At the top, you will need to write this line of code:
using UnityEngine.SceneManagement;
This allows us to call SceneManager.LoadScene.

(2) Replace the entire Update function with this one:

void Update ()
{
    if (restart)
    {
        if (Input.GetKeyDown (KeyCode.R))
        {
            SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
        }
    }
}

Emhuynh: Thanks for the quick response.
I followed your instructions:

void Update ()
{
if (restart)
{
if (Input.GetKeyDown (KeyCode.R))
{
SceneManager.LoadScene (Application.loadedLevel);
}
}
}

But I’m still receiving this error:

******Warning 1 ‘UnityEngine.Application.loadedLevel’ is obsolete: ‘“Use SceneManager to determine what scenes have been loaded”’