- Home /
Is PlayerPrefs still slow?
This article from 2011 suggests that PlayerPrefs is "really slow on iOS and even slower on Android". Is this still true in 2015 and Unity 5?
The post goes on to say:
Most likely, they are doing file I/O operations for every modification. The current PlayerPrefs class is clearly not designed to handle a larger amount of data.
Is it also still recommended that content be stored in serialized form?
Thanks.
I have used Player Prefs on Android back in 4x versions. .and it worked pretty fast.. Haven't seen any problems. Pretty sure unity 5 didnt changed much regarding this though.
Answer by SarperS · Jun 07, 2015 at 05:44 AM
PlayerPrefs actually does not do any file I/O operations unless you call PlayerPrefs.Save, so it holds the values in memory until the player quits the game, by default it saves the data on disk in OnApplicationQuit implicitly.
Also the benchmark they did is not realistic. In a real world example, if you are saving 6/7 values per second, there is something really wrong with your approach to whatever you are trying to solve.
Answer by Myzer · Jun 07, 2015 at 04:13 PM
I am by no means an expert on this, but, I can say that whenever I use it, it works perfectly fine for me. I have never noticed any sort of performance issues whatsoever with it. With that said, I should also state that, thus far, I've only had to use it for storing small amounts of data that I then use to determine simple things. For example: If, in my game the player decided to mute or lower the volume, I'd just write that value the user sets to PlayerPrefs and check it whenever it needs to be checked. So, I haven't used it for anything extravagant enough to say, but it should be fine.
Answer by Voxel-Busters · Jun 07, 2015 at 12:05 PM
PlayerPrefs works well, we dint notice any lags because of it, then again it depends on the data being serialised. FYI, Unity writes preferences to disk only when application is about quit. Check this link for more info http://docs.unity3d.com/ScriptReference/PlayerPrefs.Save.html