Using playerprefs to remember a level completion

I have a function that gets called whenever a level gets completed:

public void LevelComplete(){ //code here }

But how can I correctly use playerprefs to remember that I finished the level? there is a variable that contains the number of what level it is in but I don’t know if playerprefs has something special that can help me do this a lot easier than what I had in mind.


Since you have a variable that stores the number of level currently on you can do something like:

int levelNumber;

void Start () {
	PlayerPrefs.SetBool("Level"+levelNumber.ToString(), true);

Get the logic from above code snippet as to how you can set and get a level status using the level number you have.

Now you can set bool to be true if level is complete. And you can even check if the key exists for that level using PlayerPrefs.HasKey and if there is no key then level is not complete. But mind that PlayerPrefs are not at all secure to store level completion. User can very easily cheat.