- Home /
Question by
G_Sacristan · Aug 16, 2011 at 01:38 PM ·
playerprefscountlaunch
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!
Comment
Best Answer
Answer by Bunny83 · Aug 16, 2011 at 01:54 PM
gameLaunchCount != gameLauchCount
That's why you should use string constants
static var gameLaunchCount = "gameLaunchCount";
[...]
PlayerPrefs.GetInt(gameLaunchCount);