Implementing Multiple Game Saves (New, Load, & Save)

Easy Save 2 has been replaced by Easy Save 3, so is no longer supported.
Locked
brandoncluff
Posts: 4
Joined: Sun Dec 03, 2017 9:47 pm

Implementing Multiple Game Saves (New, Load, & Save)

Post by brandoncluff »

Hello!

I purchased Easy Save last week and I'm just starting to play around with it. So far I'm comfortable with saving simple data - such as integers, booleans, etc -- I took a look on the forums and documentation to see if there was a good method for having save slots/files, but I can't seem to find any information.

What I am working with: I have a simple prototype going where a player is able to draw a level, and then interact with it. Right now, the prototype is similar to Line Rider, if you're familiar.

What I want to do: Give the player the ability to create a new game, draw in it, play with it, save it, load it. I'd like the player to be able to save as many different games as possible. I'd like to build a save system similar to Fallout, Skyrim, or Breath of the Wild - where the save games are presented in a list with names and timestamps. I will have two game modes that will need to be saved into separate 'types' for loading purposes.

Is this possible in Easy Save?

Thank you.
User avatar
Joel
Moodkie Staff
Posts: 4846
Joined: Wed Nov 07, 2012 10:32 pm

Re: Implementing Multiple Game Saves (New, Load, & Save)

Post by Joel »

Hi there,

With regards to making the save slots, this is more of a GUI issue than an Easy Save one. However, how you would structure your Easy Save data to do this is as follows:
  • Use the filename to determine what file belongs to which save slot (i.e. Slot1.txt, Slot2.txt, etc)
  • Within that file, save a timestamp of the current time (A DateTime perhaps)
  • To get a list of all save slots, use ES2.GetFiles to get all of the filenames.
  • You can also load the timestamp you saved earlier from each file and display them to the user.
  • When a user chooses a save slot, put the corresponding filename into a static variable and always use this filename whenever saving or loading data.
With regards to saving the actual contents of your scene, it sounds like the user is instantiating prefabs, in which case the Saving, Loading and Instantiating prefabs guide gives a basic example of saving prefab instances. For a more in-depth example, see the Creating an Automatic Save Structure example.
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
brandoncluff
Posts: 4
Joined: Sun Dec 03, 2017 9:47 pm

Re: Implementing Multiple Game Saves (New, Load, & Save)

Post by brandoncluff »

Thanks for the help. I was able to get this MOSTLY done. However, I'm having issues saving complex structures in my prefabs. For example: the Line Renderer in Unity creates a Edge Collider 2D and a Line Script - which has an array of points (quite a few for complex lines). Here's a screenshot:
LineRenderer.png
LineRenderer.png (36.53 KiB) Viewed 9050 times
For additional context, my game has Undo() and Redo() methods that manipulate two lists - so each game object needs to be in the correct List slot. Again, a screenshot:
LineHistory.png
LineHistory.png (37.33 KiB) Viewed 9050 times
When I purchased ES2, I was under the impression that Saving/Loading gameObjects would be easy -- from what I'm seeing so far, I can save extremely basic types, like strings, booleans, floats, etc, but not complex objects like gameObjects. In the future, do you plan to automate this process? I'd expect to be able to say, ES4.Save().Save(thisObject, saveFile) and have it save the components, and their values and be able to ES4.Load<GameObject>(thisObject, saveFile). I want to be able to easily save scene states -- do you know how powerful that would be?

I was hoping to purchase this asset and not have to spend a bunch of time...
User avatar
Joel
Moodkie Staff
Posts: 4846
Joined: Wed Nov 07, 2012 10:32 pm

Re: Implementing Multiple Game Saves (New, Load, & Save)

Post by Joel »

Hi Brandon,

Easy Save 3, which is currently in beta, will have more in-depth support for saving GameObjects. However, it's not possible to automatically serialise most Unity classes at runtime, because Unity strips out necessary attributes during the build process. For this reason each Unity class must be manually implemented.

I've added a feature request here for these to be manually implemented. In the meantime, on how you might be able to manually add support for the type yourself here:
http://docs.moodkie.com/easy-save-2/gui ... her-types/

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
brandoncluff
Posts: 4
Joined: Sun Dec 03, 2017 9:47 pm

Re: Implementing Multiple Game Saves (New, Load, & Save)

Post by brandoncluff »

Thanks for the reply. I know we're waiting on a stable 2017 for ES3 to be released... Do you have a vague idea of when that might be?
User avatar
Joel
Moodkie Staff
Posts: 4846
Joined: Wed Nov 07, 2012 10:32 pm

Re: Implementing Multiple Game Saves (New, Load, & Save)

Post by Joel »

Hi there,

We're not waiting on a stable Unity 2017 to be released per se, but waiting for bug fixes to be applied. Currently it's not possible for us to say when this will be.

Note that we will be looking at workarounds if we're not provided with a solution from Unity before January, but this will likely require us to rewrite a very large portion of our code.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
Locked