- Home /
Saving a Dictionary To PlayerPrefs
I am attempting to save this dictionary to playerprefs:
 var playerScores = new Dictionary.<String, Dictionary.<String,double> >();
I look online but haven't found a fix to this. the issue is unity's playerprefs doesn't save dictionary's. Does anyone know a workaround or fix to this issue?
I'm deleting my prior comment; please include that in your lead next time.
Answer by NeverHopeless · Aug 06, 2015 at 06:31 AM
AFAIK, besides saving string, integer and float you can't save anything to PlayerPref. To resolve this issue, you can use Serialization to convert your object to an string representation and save it to a file.
As an starter have a look at this thread.
Also, once it is converted to a string you can also use PlayerPrefs.SetString to save it to the PlayerPrefs class but based on your comment here, saving a lot of data to PlayerPrefs can slow down it on devices.
Hope it helps!
Answer by Fira-Soft · Mar 17, 2020 at 10:09 PM
What solved for me was that Odin Inspector already serializes dictionaries, and I was already using it. So I could use JsonUtility on the class that has the dictionary and it just worked.
Your answer
 
 
             Follow this Question
Related Questions
PlayerPrefs Int to Float 1 Answer
Store individual positions of GameObjects in a string 3 Answers
Using Player Prefs 0 Answers
Can I transfer the PlayerPrefs.plist file to the iPhone? 1 Answer
What is the difference between Cache and PlayerPref? 1 Answer
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                