Question by
Segy · Feb 05, 2016 at 02:32 AM ·
playerprefsscene-loadinglevel load
Load level once
The below script is my main menu button.
How it works: That button loads a new level each time a level is passed. E.g. I pass level 2 and get to level 3, i quit game and click 'Play Game', then level 3 would load.
My problem: When I built my game and tested, it would not load any level, as it only loads a level each time it is passed. How would I add something to tell it to load level 1 when game is just downloaded, then to continue doing my following script.
Any advice or script example would be appreciated, many thanks
public void PlayGame()
{
loadingImage.SetActive(true);
if (PlayerPrefs.GetString("Level").Equals(null))
{
SceneManager.LoadScene(levelSelect);
}
else
{
levelSelect = PlayerPrefs.GetString("nLevel");
SceneManager.LoadScene(levelSelect);
}
}
Comment