Auto save bug or i miss something ?

Discussion and help for Easy Save 3
Post Reply
skeleton60
Posts: 2
Joined: Sun Jan 13, 2019 2:30 pm

Auto save bug or i miss something ?

Post by skeleton60 »

Hello,

i tried the auto save feature and it work fine saving position or variables in a script component !

but when i destroy a gameobject it will be spawned and loaded on the next start ! did i miss something ?
User avatar
Joel
Moodkie Staff
Posts: 4849
Joined: Wed Nov 07, 2012 10:32 pm

Re: Auto save bug or i miss something ?

Post by Joel »

Hi there,

As mentioned in the documentation, Auto Save saves the Components of an object. It does not save whether it has been destroyed as this is not represented by the Components.

To persist a destroyed object, you could attach a script such as this to it:
using UnityEngine;

public class SaveDestroyed : MonoBehaviour 
{
	public string guid = System.Guid.NewGuid().ToString();

	void Start () 
	{
		if(ES3.KeyExists(guid))
			Destroy(this.gameObject);
	}

	public void Destroy()
	{
		ES3.Save<bool>(guid, true);
		Destroy(this.gameObject);
	}
}
All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
skeleton60
Posts: 2
Joined: Sun Jan 13, 2019 2:30 pm

Re: Auto save bug or i miss something ?

Post by skeleton60 »

Thanks you for the answer and the code example
Post Reply