Information that will be saved permanently

Hello!
There is one thing that I don’t understand about unity. How do I save information permanently? I’m currently making an options menu were you can set up your resolution, audio, key bindings etc. I want the player to be able to close down the game and then open it up again with the same settings as before (if the player changed them). How do I do that?

Thank you.

One note to make though is that PlayerPrefs is not secure, and can be a bit inefficient to use given limited options. It’s a good way to start out, though (especially if you’re just saving simple data, such as integers, floats, and strings).

But you’ll probably need to find a nice save solution (I use Easy Save 2 from the asset store), or code your own solution for writing data to files.

There was a Unity training session about this which, if you have time, you can watch to get an idea: http://unity3d.com/learn/tutorials/modules/beginner/live-training-archive/persistence-data-saving-loading

The PlayerPrefs class provides a way of saving and retrieving data. For instance, if you wanted to save a high score, you could store it using this line…

PlayerPrefs.SetInt("Player Score", 10);

…and then retrieve it later using this line…

int score = PlayerPrefs.GetInt("Player Score");

The PlayerPrefs class can store floats, ints, and strings. Refer to the script reference on PlayerPrefs for more information.