I am still pretty new at unity and also programming so I’m having some trouble getting ES3 to work as a want it. So for I managed to save player position and having multi saving/loading slots. Now I can’t figure it out, how to save destroyed object. I went through the docs but can’t figure it out. Script that I found in an old topic doesn’t work for me also, because destroyed object are not loaded in every other saved game and even if I start the new game object with this script that I destroy in previous run are destroyed. To bear in mind I’m still learning so I don’t understand every aspect of this script.
Code: Select all
public class SaveDestroyed : MonoBehaviour
{
public string guid = System.Guid.NewGuid().ToString();
static bool isApplicationQuitting = false;
void Start ()
{
if(ES3.KeyExists(guid))
Destroy(this.gameObject);
}
void OnDestroy()
{
if (gameObject.scene.isLoaded && !isApplicationQuitting)
ES3.Save<bool>(guid, true);
}
void OnApplicationQuit()
{
isApplicationQuitting = true;
}
}
Any suggestion would be nice. Thank you!