Save a gamemanager

Discussion and help for Easy Save 3
User avatar
Joel
Moodkie Staff
Posts: 4824
Joined: Wed Nov 07, 2012 10:32 pm

Re: Save a gamemanager

Post by Joel »

zay_altick wrote: Sat Apr 17, 2021 2:09 pm Thanks! Just noticed that. Sorry, that first glitch seemed to really mess with me causing confusion haha
It looks like the GameObject I wanted to have saved is working, but it's creating multiple instances of it every time the project replays. A bit strange since I thought it wouldn't do that if there's already one in the scene
Hi there,

This is likely because you're creating your own instance of the GameObject as well as loading it. In this case you should follow the Auto-saving Prefab Instances section of the Auto Save guide:
https://docs.moodkie.com/easy-save-3/es ... hout-code/

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
zay_altick
Posts: 16
Joined: Sat Apr 17, 2021 11:42 am

Re: Save a gamemanager

Post by zay_altick »

Thanks for the link!

After reading and trying to implement it, I think I'm halfway there. I'm trying to set it up in a way that it remembers only 1 variable "savedLevel". I want this saved because in the event thee player quits the application at say "Level 5", they should be able to go back to that location after the main menu. But for some reason, this isn't saving as I thought it would.

This variable is in the "Scene Load" script
Scene Load.png
Scene Load.png (143.7 KiB) Viewed 1584 times
zay_altick
Posts: 16
Joined: Sat Apr 17, 2021 11:42 am

Re: Save a gamemanager

Post by zay_altick »

*UPDATE*

It seems to only save the value if I MANUALLY change that variable in-game which is a little strange

I'm changing the variable by using a function that is called every time a new scene is loaded.


I think this is because I'm never actually saving the scene when I enter a new Scene. This is probably where I'll need to start coding in points to save the game
User avatar
Joel
Moodkie Staff
Posts: 4824
Joined: Wed Nov 07, 2012 10:32 pm

Re: Save a gamemanager

Post by Joel »

I'm changing the variable by using a function that is called every time a new scene is loaded.
Are you sure that the new value isn't overwriting the loaded value? If so, you will need to load after changing the value.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
zay_altick
Posts: 16
Joined: Sat Apr 17, 2021 11:42 am

Re: Save a gamemanager

Post by zay_altick »

Oh you're right! Thanks for pointing that out. The right value is saved to the variable now!

The last thing I need to do is just figure out how I can Load my gamemanager on the "main menu"

I mentioned this earlier, but when the player boots up the game for the first time, the manager won't be there until they reach level 1.

After they start level 1, from that point, the gamemanager should ALWAYS load in the main menu. Would I need to put an "Easy Save" gameobject in the main menu in order for this to work?
User avatar
Joel
Moodkie Staff
Posts: 4824
Joined: Wed Nov 07, 2012 10:32 pm

Re: Save a gamemanager

Post by Joel »

Hi there,

To do this you would need to load the data using code rather than Auto Save. Auto Save is only intended to save data in scenes, so it's not intended to load data outside of the scene in which it was saved.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
zay_altick
Posts: 16
Joined: Sat Apr 17, 2021 11:42 am

Re: Save a gamemanager

Post by zay_altick »

Gotcha! So if I use Easy Save in code, I wouldn't need to add an "Easy Save Gamemanager to my scenes right? At the moment, it works as intended, but I'm not sure why. I placed this line of code

Code: Select all

 ES3.Save("level", savedLevel)
In a few areas and in void Start of my created Gamemanager that appears in the beginning of my "main Menu" Scene I run

Code: Select all

  savedLevel = ES3.Load("level", savedLevel);

And it works as intended. I don't have a single "Easy Save Manager" in any of my scenes anymore which makes me believe my code is why it works, but I just want to make sure.
User avatar
Joel
Moodkie Staff
Posts: 4824
Joined: Wed Nov 07, 2012 10:32 pm

Re: Save a gamemanager

Post by Joel »

Hi there,

You only need the Easy Save Manager in your scene if you're using Auto Save, or saving reference types. So assuming your savedLevel variable is a string or value type, it looks good to me :)

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
zay_altick
Posts: 16
Joined: Sat Apr 17, 2021 11:42 am

Re: Save a gamemanager

Post by zay_altick »

Awesome! Thanks a ton for the help!
Post Reply