Hi - I'm trying to save / load an array but keep hitting errors. Can anyone please help describe what I'm doing wrong here and how to fix it up? Many thanks in advance!
int[] ii = new int[2];
ii[0] = 99;
ii[1] = 100;
ES3.Save("key", ii);
int[] kk = ES3.Load<int[]>("key");
Debug.Log(kk[0]); // Expected this to print 99, but fails as kk is null.
Debug.Log(kk[1]);
Have also tried using LoadInto (with a pre-allocated kk of the right size) but that returns an error "Object reference not set to an instance of an object", so presume that I've just misunderstood how to use arrays completely here!
using UnityEngine;
public class Test : MonoBehaviour
{
void Start()
{
int[] ii = new int[2];
ii[0] = 99;
ii[1] = 100;
ES3.Save("key", ii);
int[] kk = ES3.Load<int[]>("key");
Debug.Log(kk[0]); // Expected this to print 99, but fails as kk is null.
Debug.Log(kk[1]);
}
}
See the attached image for the output. Please could you create a new project with the above script and private message it to me if it's still not working for you?
I've managed to create a repro scenario - in the runtime settings window just change the default encoding from JSON to Binary_Alpha. With the former the script works, and with the latter it doesn't. Is this a bug or expected behaviour?