using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class GameManager : MonoBehaviour {
public static int currentScore;
public static int highScore;
public static int currentLevel= 0;
public static int unlockedLevel;
public static void CompleteLevel()
{
if (currentLevel < 2) {
currentLevel++;
Application.LoadLevel(currentLevel);
} else {
print ("you win");
}
}
Application.LoadLevel() has been deprecated since (I think) 5.2. You use SceneManager now so change your code to the following.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class GameManager : MonoBehaviour
{
public static int currentScore;
public static int highScore;
public static int currentLevel= 0;
public static int unlockedLevel;
public static void CompleteLevel()
{
if (currentLevel < 2) {
currentLevel++;
SceneManager.LoadScene(currentLevel);
}
else
{
print ("you win");
}
}
Also, I forgot a bracket in my code so don’t forget to add a final bracket at the end!
The most preferred way to reload the current level is to actually remove the variable currentLevel and replace the function with SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);, although that’s a preference by me so that way I don’t have an extra variable and the code automatically works on any level application.