public static int score;
Text text;
void Awake ()
{
text = GetComponent<Text> ();
score = 20;
}
void Update ()
{
text.text = "0" + score;
if(ScoreManager.score == 00)
{
if(Application.loadedLevel == "Level1")
{
PlayerPrefs.SetInt("Level",1);
Application.LoadLevel("Mission");
}
if(Application.loadedLevel == "Level1.2")
{
PlayerPrefs.SetInt("Level.2",1);
Application.LoadLevel("Mission");
}
if(Application.loadedLevel == "Level1.3")
{
PlayerPrefs.SetInt("Level.3",1);
Application.LoadLevel("Mission");
}
}
}
}
As explained in the documentation, Application.loadedLevel gives you an integer value of the level index that was last loaded.
As explained in the error message, Application.loadedLevel == "Level1"
is therefore incorrect, because you’re trying to compare an int with a string.
And the solution is to use Application.loadedLevelName :
if(Application.loadedLevelName == "Level1")
etc. etc.
If you installed 5.3 then Application.loadedlevel() isn’t used anymore. A new framework is used called SceneManager, It is exactly the same as LoadedLevel. at the beginning of your script put.
C#–> using UnityEngine.SceneManagement;
Js—> import UnityEngine.SceneManagement;
then replace all the “Application.loadedLevel” with “SceneManager.LoadedScene()”
it just worked with mine so it should work with your project