I just thought of an issue and not sure how to solve it then....
This script writes directly to the save file that it was destroyed. But what if the player saves, then picks up the item and plays for another 10 minutes then quits without saving. (other than setting a save on quitting or scene change) Is there a way to keep a list of what was destroyed first THEN on a save game write those changes and clear a list?
Code: Select all
public string guid = System.Guid.NewGuid().ToString();
void Start ()
{
Invoke(nameof(DestroyMe), .3f);
}
public void DestroyMe()
{
// Debug.Log("I am destroying it");
if (ES3.FileExists("SaveFile.notso") && ES3.KeyExists(guid))
{
if (ES3.KeyExists(guid))
{
Destroy(this.gameObject);
}
}
}
void OnDestroy()
{
if (gameObject.scene.isLoaded && !NotsoSave.isApplicationQuitting)
{
Debug.Log("I have just destroyed : " + guid);
ES3.Save<bool>(guid, true);
}
}