using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
public class GameOver : MonoBehaviour {
public GameObject gameOverScreen;
public Text secondsSurvivedUI;
**ERROR**bool gameOver;
// Use this for initialization
void Start () {
FindObjectOfType<PlayerController> ().OnPlayerDeadth += OnGameOver;
}
// Update is called once per frame
/*void Update () {
if (gameOver) {
if (Input.GetKeyDown (KeyCode.Space)) {
SceneManager.LoadScene (0);
}
}
}*/
void OnGameOver(){
gameOverScreen.SetActive (true);
secondsSurvivedUI.text = Mathf.RoundToInt(Time.timeSinceLevelLoad).ToString();
gameOver = true;
}
//UI Input
***ERROR***public void StartNewGame(){
Application.LoadLevel ("Game");
}
public void exit (){
Application.Quit();
}
}
Why don’t you read the error message next time? This occurred when you’re updating Unity to a newer version while your script still using the old version API.
UnityEngine.Application.LoadLevel(string) - has been removed in new version.
UnityEngine.SceneManager.LoadScene(string) - use this command instead.
So basically:
Application.LoadLevel (“Game”);
should be
SceneManager.LoadScene(“Game”) ;
It literally gives you the answer within the error.
Application.LoadLevel (string); is obsolete. Meaning it is out of date and no longer used.
To fix your problem,
replace this : Application.LoadLevel (string);
With this : SceneManager.LoadScene(string) ;