PlayerPrefs.GetInt(str: String) always 0

Hi!

function Awake()
{
    if(!PlayerPrefs.HasKey("gameLaunchCount"))
	{
		PlayerPrefs.SetInt("gameLaunchCount",1);
	}
	else
	{
		PlayerPrefs.SetInt("gameLaunchCount",PlayerPrefs.GetInt("gameLauchCount")+1);
	}
	
	PlayerPrefs.Save();
	print(PlayerPrefs.GetInt("gameLauchCount"));
}

Always prints 0

Why isnt this one working? I cant figure out…

Thanks in advance!

1 Answer

1

gameLaunchCount != gameLauchCount

That's why you should use string constants static var gameLaunchCount = "gameLaunchCount"; [...] PlayerPrefs.GetInt(gameLaunchCount);