- Home /
Is "PlayerPrefs" (Get/Set) slow ?
I need to pass some variables (lets say 30 or 40, mostly Int) from one script to another. But not just on "Start", but whenever the user hits a "Menu" button.
I could use PlayerPrefs.SetInt and PlayerPrefs.GetInt to write/read those variables or thatd be too slow comparing to the usual method of passing parameters (lets say fill an array with those ints or something and pass it to the other script when the user hits the "Menu" btn) ??
I dont actually NEED these data to be persistent, but you never know..... if the two approaches are similar regarding the speed, Ill prefer the PlayerPrefs road..
Thks in advance!
Answer by xCRKx TyPHooN · Apr 07, 2011 at 09:36 PM
Unless you are having some issues with speed, I wouldn't even worry about it. If it's just menus where you need to pass parameters like this I see no reason why you can't use the Get() and Set() functions. The function itself may be "slow" in a continuous update loop, but for a one time click event it should be fine.
Answer by esdin · Jul 30, 2011 at 09:29 PM
There is a currently existing bug where activating the Keyboard view in Unity iOS applications can result in a severe increase in PlayerPrefs write times.
In general, you can optimize your PlayerPrefs call by writing to your own hashtable and then loading and flushing all values from device playerprefs at application launch and quit.
Here's an excellent post with a PlayerPrefs override class you can add to plugins. While the class included may not be the perfect fit for your project, it is definitely a good example to start from. http://www.previewlabs.com/writing-playerprefs-fast/
Your answer
Follow this Question
Related Questions
(2 hidden skinned meshes) or (1 extra draw call) for character props? 2 Answers
Loading a prefab over multiple frames. 1 Answer
Does anyone know why continuously saving to playerprefs would cause a performance drop ? 0 Answers
Game build works fine in Android but is jittery in iPhone. 0 Answers
Increase in speed in iPhone Advanced 1 Answer