Search Unity

Must use Playerprefs.save ()?

Discussion in 'Scripting' started by Apiweb, Jan 9, 2014.

  1. Apiweb

    Apiweb

    Joined:
    Nov 26, 2011
    Posts:
    57
    It is the first time I am working with PlayerPrefs.

    I did a test, and used PlayerPrefs.SetInt ("Test", 1);

    And I saw that he already saved without me having to call the PlayerPref.Save() function

    Other words at what time I should use the Save function?
     
  2. Glockenbeat

    Glockenbeat

    Joined:
    Apr 24, 2012
    Posts:
    670
    Usually you will need to call Save(). However PlayerPrefs are also saved when the application quits, so there might be a chance that you set the value before and now see the previous result.
     
  3. BinaryOrange

    BinaryOrange

    Joined:
    Jul 27, 2012
    Posts:
    138
    I'd use it in a custom SaveGame() function that's called when the player chooses to quit the application. Although PlayerPrefs do seem to save automatically, it's best to be safe than sorry! :cool: