UnityEngine.Application.LoadLevel(String) is obsolet!

When trying to work my main menu for one of my creations, I was repeatedly getting this error/warning, that did although lead into a larger problem. I do not understand what I am doing wrong… If anyone can help, it would be greatly appreciated… The error occurs on line 10 below


function OnGUI(){
	if(menu){
			GUI.Box(new Rect(Screen.width /2 -100,Screen.height /2 -120,200,160), "Game Over");
			if(GUI.Button(new Rect(Screen.width /2 -80,Screen.height /2 -80,160,40), "Retry")) {
				LoadData();
			}
			if(GUI.Button(new Rect(Screen.width /2 -80,Screen.height /2 -20,160,40), "Quit Game")) {
				mainCam = GameObject.FindWithTag ("MainCamera").transform;
				Destroy(mainCam.gameObject); //Destroy Main Camera
				Application.LoadLevel ("Title");
				//Application.Quit();
			}
	}
}

The problem is that the LoadLevel method is obsolete. i.e. your code is out-of-date and will stop working in a future version of Unity as it relies on features that are being removed.

The correct updated approach is to use the SceneManager: