Store Array in PlayerPrefX in Unity JS

Hi. In Unity Javascript, I cant make PlayerPrefsX to store Array of Strings.

Here are the requirements-

  1. I have an Array of Strings.
  2. Doing Array Push in that.
  3. 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.

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()