Answer the question
In order to leave comments, you need to log in
Why does this code have such a result?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class test : MonoBehaviour {
public Save sv;
public void Awake()
{
sv = JsonUtility.FromJson<Save>(PlayerPrefs.GetString("SV"));
Debug.Log(sv.test.Length);
Debug.Log("Begin - " + sv.achieveStatus.Length);
}
public void OnApplicationQuit()
{
Debug.Log(sv.test.Length);
Debug.Log("End - " + sv.achieveStatus.Length);
PlayerPrefs.SetString("SV", JsonUtility.ToJson(sv));
PlayerPrefs.Save();
}
}
[System.Serializable]
public class Save
{
public byte[] test;
public byte[,] achieveStatus;
}
public byte[] test = new byte[3];
public byte[,] achieveStatus = new byte[3,3];
Answer the question
In order to leave comments, you need to log in
not "not saved".
and the Json serializer does not know how to work with multidimensional arrays.
replace it with something in the spirit of .. an array of arrays or a list of lists))
this can be serialized, and access to the same indexes will remain.
For JSON in C#, there is an excellent class generation service and library: Newtonsoft.Json
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question