Switching Scenes On Button Click

I have gone through a few of the tutorials on the site, have watched and followed with a number of independent tutorials on YouTube, and have read as much documentation and forum threads as I could understand before coming to ask this.

Basically, I have created two game Scenes, and have a UI Canvas for each of them with some buttons. The main thing I am trying to do is make it so that I can switch back and fourth between them with the appropriate button. Here is the script I wrote for the first:

using UnityEngine;
using System.Collections;

public class SceneManager : MonoBehaviour {

	public void OnWorldMap()
    {
        Application.LoadLevel("WorldMap");
    }
}

Microsoft Visual Studio and Unity both claimed that Application.LoadLevel is outdated, so I tried switching to the new form:

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

public class SceneManager : MonoBehaviour {

	public void OnWorldMap()
    {
        SceneManager.LoadScene("WorldMap");
    }
}

This however, shoots an error saying that SceneManager does not contain a definition of LoadScene. I know that this is something I must have setup incorrectly, but I’ve yet to be able to figure out why. And even using the outdated code line it fails to switch scenes from my first “Town View” scene to the “World Map” scene (both of which I have in the build settings, as index 0 and 1 respectively).

Any help with this would be extremely appreciated, though if I manage to figure this out in the meanwhile I’ll close out the question.

DON’T call your script SceneManager - unity has it’s own.

the reason you get the error is because you haven’t defined your own LoadScene method, and nor should you. change the name of the script and it should work for you.