- Home /
Is there a way to loop through all the keys in PlayerPrefs?
PlayerPrefs is similar to a hash or dictionary, and I'm fairly sure you can loop through a hash. Is there a way to loop through PlayerPrefs?
Answer by yoyo · Feb 03, 2011 at 11:36 PM
Unfortunately no, the PlayerPrefs class only exposes get/set methods per key, but no way of iterating the keys. There is likely an internal data structure that could be iterated, but the Unity devs have not made it accessible, at least not through the API. (Note that the API is a thin .NET wrapper on the underlying unmanaged API, so you can't cheat your way in with Reflection either.)
The PlayerPrefs docs reveal where the data is stored, so it looks as though you could iterate the keys by going to the Preferences file on a Mac, or the registry on a PC, but I'm guessing prefs in a web player aren't accessible.
Ok, thanks for the information. I'll have to look for another solution to my problem.
Your answer
Follow this Question
Related Questions
Storing game data for game attributes? 1 Answer
Score not resetting 3 Answers
Nullreferencexception using PlayerPrefs.GetInt and GetString 1 Answer
PlayerPrefs issue 0 Answers
Is it possible to use ToString to format a playerpref int value? (JS) 0 Answers