I'm trying to user PlayerPrefs to control which levels are unlocked.
When the end of each level is reached, the same script is used to keep track. For example, in the update of the EndScript:
function update()
{
if (finished == true && PlayerPrefs.GetInt("FinishedLevel") <= Application.loadedLevel)
{
PlayerPrefs.SetInt("FinishedLevel") ++ ;
}
}
This is clearly wrong but I put the ++ there for illustrative purposes. Is there anywhere I can 'add one'?
I can't add a '++'after the brackets either, as I get an error.
The logic being that at the end of each level I check if the FinishedLevel total is equal to the current level, if not, add one. Therefore I can dynamically keep track of how many levels have been finished and which levels are available from the menu.
Any tips on how to achieve this?
↧