Some preliminary testing showed that everything seemed to be fine but I soon found a few issues:
The actual marble object, which has a script that stops it from sleeping (prevents physics bugs) and as-well as resetting it when the simulation stops and enabling it's rigidbody when the simulation starts (player has control over whether or not the simulation is running by clicking a button), wasn't being saved.
I made a new type for it but then things seemed to have become worse. Some blocks now just become pink (caused by it being loaded with extra materials in it's renderer's materials array despite it only having one at the time of saving) and the marble creates an error saying it doesn't have a rigidbody when it does (I assume being caused by the fact the script is loaded before the rigidbody?)
To save, I just do (doesn't include the code for checking if save already exists. It's just a simple ES3.KeyExists if-statement)
Code: Select all
ES3.Save(saveNameInput.text, GameObject.Find("TrackParent"));
Code: Select all
//Delete currently loaded map
Destroy(GameObject.Find("TrackParent"));
//Sometimes map won't be loaded but TrackParent is still destroyed. I guess this is some sort of async issue??? Putting it into a coroutine with a delay to when ES3.Load is called fixes it.
StartCoroutine(loadMap());
//Hide load dialogue screen
ToggleLoadDialogue();
Code: Select all
IEnumerator loadMap()
{
yield return new WaitForSeconds(1f); //Test delay
GameObject parent = (ES3.Load<GameObject>(savedTracks.options[savedTracks.value].text));
parent.transform.position = Vector3.zero;
}