loop through playerprefs ints and find specific one

I’m using playerprefs ints like so:


when the int is 1 it’s unfinished and when tis 2 it’s finished.

How can I loop through all my LevelC’s till I find the one that isn’t 2 anymore so let’s say the player finished LevelC5=2 but LevelC6 is still 1 how can I make the script understand that I have to continue on level5 then?


I would recommend puting every piece you want to check into an int array. Then use something like

Public int[] levelsDone;

for(int i = 0; i < levelsDone.Length; i++){

It goes through each piece of the array and does whatever’s in the {}. Reference i for what index it’s checking.

Okay I fixed it myself,

for anyone who would like to know what I did:

		for(int i=0; i < 31; i++){
			int LevelDone = PlayerPrefs.GetInt("LevelC"+i.ToString());
			int j = i+1;
			if(PlayerPrefs.GetInt("LevelC"+i.ToString()) == 2 &&
			   PlayerPrefs.GetInt("LevelC"+j.ToString()) == 1){