Hi guys!
I just purchased Easy Save 3 yesterday and reading all the documentation that came with it I still have a few questions. I've been using PlayerPrefs thus far (not too happy with it, that's why I got ES3) and from what I've seen so far ES3 is a way better version of it including some other extra features. I'm still really new when it comes to any saving system.
But what I don't really understand is how gameObjects (prefabs) are saved within Unity. I work with multiple scenes, and one scene (house) has a key on the table that can be picked up and goes into the players inventory and the gameObject itself gets destroyed. When the player goes back outside (outside scene) I managed to save the player's inventory with ES3. But when I go back inside, the key is still on the table.
How can I use ES3 to let the key gameObject know that it has been destroyed or deactivated so it won't appear on the table again once it has been picked up previously when the player goes back into the house?
thanks in advance!
Saving state of gameObject
Re: Saving state of gameObject
Hi there,
You can use the Save Destroyed script to save the destroyed state of a GameObject:
All the best,
Joel
You can use the Save Destroyed script to save the destroyed state of a GameObject:
Code: Select all
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
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;
}
}
Joel
Re: Saving state of gameObject
Holy crap! Thanks for the fast reply! I tried your script and it works like a charm! Thank you very much!!
Re: Saving state of gameObject
Glad that's working well for you, let me know if you run into any other issues
All the best,
Joel
All the best,
Joel