I am trying to understand how to use the player prefs with a simple method; Basically I want to instantiate a prefab (or play a sound) each time I report an achievement to Game Center - not every time I am reaching that particular level. So I use this in a function where
if (_level == 21)
{
shieldObject.renderer.material.mainTexture = shieldTexture[0]; //also change some textures to make it pretier
if (PlayerPrefs.GetInt("Player Achievement", 1))
{
GameCenter.ReportAchievement("achievement1");
Debug.Log("Report achievement and instantiate the reward only once, not everytime we are on this level");
}
}
I am not sure when to set the value and when to read them. Following my artist logic I ended up with something really silly: when I reach the level I want I save the value. But this exactly where I want to read it too. Please help. Or laugh at me
if (_level == 21)
{
PlayerPrefs.SetInt("Player Achievement", 1);
}