This is for locking
public Button[] levelButtons;
private void Start()
{
int levelReached = PlayerPrefs.GetInt("levelReached",1);
for (int i=0; i < levelButtons.Length; i++) {
if (i + 1 > levelReached) {
levelButtons*.interactable = false;*
levelButtons*.image.color = Color.red;*
}
}
}
These are from end of each levels:
1:
PlayerPrefs.SetInt(“levelReached”, 2);
2:
PlayerPrefs.SetInt(“levelReached”, 3);
3:
PlayerPrefs.SetInt(“levelReached”, 4);
So the problem is when i finish level 2, I see level 3 and 4 as unlocked and when i play 3rd level and finish it, it locks level 4 again. Can anyone see the reason?