I need my game to remember what level the player was on when they left the game so they don’t have to start from the beginning when they close their browser etc.
I have been reading up on using Player Preferences with an ints etc. Simple enough i’m sure i will be able to do it. The only thing i’m not clear on if this just stores the information while you’re playing the game or if it will remember it every time you close the window and not forget it until you empty your cache.
Can anyone give me some tips or just let me know if it will work?
On Web players, PlayerPrefs are stored in binary files under ~/Library/Preferences/Unity/WebPlayerPrefs on Mac OS X and %APPDATA%\Unity\WebPlayerPrefs on Windows. There is one preference file per Web player URL and the file size is limited to 1 megabyte. If this limit would be exceeded, SetInt, SetFloat and SetString will not store the value and throw a PlayerPrefsException.
I believe it saves it to disk. You could always test it and make sure, though.
You could also use a simple dictionary. I believe there is a way to save data in a cookie or something similar, so you’d have to rework the save/load a little.
You just use a “key” to search for the value. So you store data in pairs: (“key”, “value”).
This structure is pretty useful since its easy to visualize. Performance-wise - not so friendly though, so I wouldn’t recommend saving a large amount of data that needs to be retrieved relatively quickly.
There’s a question similar to this one! Maybe you could be interested in the answer of mine, as a guide.
And don’t worry about their deletion. As Lo0Nhutik said, they are stored in the registry.