I am developing a mobile game where I need to load a 4D 60X40X60X40 integer array of about 17MB. I am currently reading the data in JSON and deserialising in Unity using SimpleJSON.cs .
The problem arises when parsing the string using SimpleJSON. The game hangs and takes about 30 seconds to load the file.
I have tried using IJobs but they do not allow usage of strings (non-blittable).
The main priority is the hanging part. It does not allow me to give feedback to the user while they wait for the JSON to load. Of course, lowering the loading time and any tips surrounding it would be really helpful.
My code:
IEnumerator StartLoadFiles()
{
// Wait to give time for the game to load everything else
yield return new WaitForSeconds(1f);
/// First read the transition matrices. We are using TextAsset
/// because of compatibility issues with Android.
TextAsset file;
yield return file = Resources.Load(transitionPath) as TextAsset;
loadingSlider.value = 0.3f;
string transitionString = file.ToString();
loadingSlider.value = 0.5f;
/// We are using SimpleJSON.cs as of now. Maybe there is
/// something faster out there... (Here is where it hangs)
JSONNode N;
yield return N = JSON.Parse(transitionString);
loadingSlider.value = 0.7f;
}
Edit: I am already using a coroutine with no difference.