- Home /
Store Array in PlayerPrefs?
Is this possible? I've not been able to figure out how to get this to work.
Answer by Umai · Dec 25, 2014 at 07:54 AM
As noted, use this now. The accepted answer site is dead at this time.
This would work, but unity no longer supports Javascript, any fixes?
Answer by Eric5h5 · Jul 15, 2010 at 04:12 AM
I wish I could up-vote this answer more than once. Thanks a bunch!
You lucky bastard.. I cant up-vote this, or any other answers at all. Well, there is (again) +1 for Eric5h5 in my $$anonymous$$d :)
Btw there is actually new version of ArrayPrefs: http://wiki.unity3d.com/index.php/ArrayPrefs2
Please delete this accepted answer or update the link since this one is dead.
Answer by franbat · Aug 18, 2015 at 04:25 AM
I had the same problem and I thought the solution:
public int [] puntaje;
for(int i=0;i<puntaje.Length;i++){
PlayerPrefs.SetInt("Puntaje"+i,puntaje[i]);
}
for(int i=0;i<puntaje.Length;i++){
print(PlayerPrefs.GetInt("Puntaje"+i));
}
That creates a separate entry for each item, though, and there's no indication of how many items are in the array, so it's easy to break. ArrayPrefs2 is more efficient, more robust, and simpler to use.
Answer by samf1111 · Jul 20, 2020 at 12:04 AM
my solution was to store my variables in a string and separate them with '\n'. it only works for strings that have no '\n's in them though.
Your answer
Follow this Question
Related Questions
[SOLVED] Problem with "foreach". 1 Answer
Trying to save/load from PlayerPrefs to Array and vice-versa 1 Answer
Manipulate arrays in Inspector with Editor Script? 2 Answers
Array problem -3 Answers
Access a String array in one script from another script 0 Answers