- Home /
Other: Solved by poster
Using PlayerPrefs to save a C# Generic List
I have a list of Times taken for you to complete each level.
[SerializeField] public List<float> BestTimes = new List<float>();
But i can't figure out how to save and reload all its floats. I'm currently using PlayerPrefsX(ArrayPrefs2) by doing this.
to save: PlayerPrefsX.SetFloatArray("BestTimes", levelselect.BestTimes.ToArray());
to load: BestTimes.AddRange(PlayerPrefsX.GetFloatArray("BestTimes"));
But the list just returns as all zero when i try and load them? Any help? :D
Using ToArray()
and AddRange()
should be O$$anonymous$$. There must be a problem in either PlayerPrefsX.SetFloatArray()
, PlayerPrefsX.GetFloatArray()
, or the code you use when you "load them".
Well that gems article has the code for saving a generic list (of classes, but floats are just fine) to PlayerPrefs or a file.
Follow this Question
Related Questions
Need help with converting an array to a list in C#` 4 Answers
Distribute terrain in zones 3 Answers
A node in a childnode? 1 Answer
Why is everything being set the same? Please Help! 1 Answer
How do I save a custom class of variables to playerprefs? 2 Answers