Auto Save

Discussion and help for Easy Save 3
Post Reply
Squashyyy
Posts: 3
Joined: Tue Apr 28, 2020 6:32 pm

Auto Save

Post by Squashyyy »

Hola,

So I'm really sorry for asking such an annoying question that could probably be googled (too noob to find the answer xd) & I'm still a beginner when it comes to coding.

ANYWAYS. So I was able to figure out how autosave works and was able to attach the script into my gameobject the thing is when I start the game and then close it I can see that the file path thingi gets updated but I have no idea how to load it afterwards. I have already checked around on the website and read the docs but for whatever reason I can't understand how keys work, is it something I'm supposed to add or is it something that's already added?

Basically what I'm trying to load is numbers that're stored in double, so I attached the auto save script to the gamemanager (where all my numbers are stored). So what I tried was adding a load into a void start in the same script which basically gave me this error: KeyNotFoundException: Key "GameManager" was not found in file ---- /SaveFile.es3". Use Load<T>(key, defaultValue) if you want to return a default value if the key does not exist.

Basically what I'm trying to ask is what key am I supposed to use or like am I supposed to create one or or orrr like what xD?

PS. Once again sorry for asking such a stupid question :P

- Squash
User avatar
Joel
Moodkie Staff
Posts: 4826
Joined: Wed Nov 07, 2012 10:32 pm

Re: Auto Save

Post by Joel »

Hi there,

I moved this thread as this appears to be Easy Save 3 related rather than Easy Save 2.

Auto Save automatically does the saving and loading, so you don't need to call the Easy Save methods.

However, if you only want to save a double it would be more efficient to use ES3.Save, rather than saving the entire GameObject. In this case you could add something like this to the OnDestroy() method to save your double when the scene exists or the application is quit:
ES3.Save<double>("myDouble", myDouble);
And then something like this to the Start() method to load it when the scene loads:
myDouble = ES3.Load<double>("myDouble");
All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
Squashyyy
Posts: 3
Joined: Tue Apr 28, 2020 6:32 pm

Re: Auto Save

Post by Squashyyy »

Hello,
Thanks for your fast answer ;D

I understand now that auto save both saves and load it for you but I still don't get why I keep getting the error about "NullReferenceException: Object reference not set to an instance of an object
ES3AutoSaveMgr.AddAutoSave (ES3AutoSave autoSave) (at Assets/Plugins/Easy Save 3/Scripts/Auto Save/ES3AutoSaveMgr.cs:85)"

I have around 30 doubles I think so I thought it would be better to just add Auto save directly onto the gameobject instead of making lots of small codes for it.

& my bad didn't know that there was a general discussion for Easy save 3
User avatar
Joel
Moodkie Staff
Posts: 4826
Joined: Wed Nov 07, 2012 10:32 pm

Re: Auto Save

Post by Joel »

Hi there,

I'm not sure you mentioned the NullReferenceException in your first message, but I think I'm able to replicate this at my end. If you private message me your invoice number I can send over an update for this.

Just to clarify, you can also use Easy Save to save an entire script. So if you have a script called MyScript with 30 double fields, you can save them all like this:
ES3.Save<MyScript>("myScript", myScript);
And then you can load them into an existing instance like this:
ES3.LoadInto<MyScript>("myScript", myScript);
All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
Post Reply