- Home /
Saving with PlayerPrefs? How it works?
Can somebody explain how saving and loading with PlayerPrefs works? Id like to make a saving system for my game but i've never done anything like this before, if there is a better way of saving and loading please help!
Thanks!!!
Answer by syclamoth · Oct 26, 2011 at 09:28 PM
I would implement save-games using some kind of serialization, not using PlayerPrefs. PlayerPrefs saves values to either the registry on windows, or a plist file in your library folder on MacOS. Saved games are likely to be too large, and use too many data types which are not compatible with the preferences, that it would be impractical to use them. Work out exactly what information needs to be stored between sessions, put it all in one object (not a gameObject, I mean something which can be serialised into a datastream of some kind) and then write all of that to a file. Look up System.IO.
Don't ask me for Javascript code for this. I can only help you in C#, here.