Why is PlayerPrefs Not Saving?

Hi guys,

Really stupid question, but I can’t figure out why PlayerPrefs isn’t saving?

var total:int=0;
var one:int=1;

function Awake () {
	PlayerPrefs.SetInt("total", one);
	PlayerPrefs.Save();
	print(zero);
}

Shouldn’t this be adding +1 to total every time the script is called?

What am I doing wrong here?

Thanks.

You aren’t using the total variable, if you want to add one to the total variable and then save the change it would have to look something like this:

var total:int=0;
var one:int=1;

function Awake () 
{
   total = PlayerPrefs.GetInt("saved_total"); //set the total variable to the previously saved value
   
   total += one; //add one to total
   
   PlayerPrefs.SetInt("saved_total", total); //set the new total value
   PlayerPrefs.Save();
}