- Home /
Store Array in PlayerPrefX in Unity JS
Hi. In Unity Javascript, I cant make PlayerPrefsX to store Array of Strings.
Here are the requirements-
I have an Array of Strings.
Doing Array Push in that.
Now I want to store the item in PlayerPrefX
What I did is-
var storedScoresArr:Array = new Array();
storedScoresArr.Push(scoreDetails);
PlayerPrefsX.SetStringArray("ScoreDetails", storedScoresArr); // Gives Error
P.S I know if I do like the following, it will work; but cant do an Array Push.-
var storedScoresArr:String[] = ["abc", "xyz"]; // it will work
// But doesn't support ARRAY PUSH
Please help with any workaround or if there is any way to convert the Array to String[] just before storing in PlayerPrefsX.
Answer by NeverHopeless · Aug 25, 2015 at 06:22 AM
PlayerPrefsX doesn't support JSArray it must be converted to a builtin array []
. You can use ToBuiltin
function to convert to builtin array. Have a look at similar thread. You may also use .Net's System.Collections.Generic.List<T>
and call list.ToArray()
Your answer
Follow this Question
Related Questions
PlayerPrefsX Question 1 Answer
Saving Array Objects in Android. 0 Answers
PlayerPrefsX plugin error when build for windows store 3 Answers
How to save an array to PlayerPrefs? 1 Answer
PlayerPrefsX IntArray 1 Answer