Save and Load Prefab Instances using Auto Save

Examples which use the ES3AutoSave and ES3Prefab Components, which do not require code.
User avatar
Joel
Moodkie Staff
Posts: 4986
Joined: Wed Nov 07, 2012 10:32 pm

Save and Load Prefab Instances using Auto Save

Post by Joel »

This is a basic example of saving and loading prefabs which are instantiated at runtime, using the ES3 Auto Save and ES3 Prefab Components provided with Easy Save. These Components are attached to the prefabs we are going to instantiate.

ES3 Auto Save loads any saved prefabs when the scene is loaded, and saves instantiated prefabs when the application is quit or paused.

Note:
  • Easy Save should be installed in your project before importing this example. The example is located in Assets/Easy Save 3/Examples/.
  • All examples are only provided as an educational sample, and may need modification for your purposes. They are provided without warranty.
Attachments
Saving and Loading Prefabs Instantiated at Runtime using Auto Save.unitypackage
(52.33 KiB) Downloaded 671 times
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
EasySaver
Posts: 5
Joined: Mon Aug 06, 2018 1:33 pm

Re: Save and Load Prefab Instances using Auto Save

Post by EasySaver »

Hey! Thanks for the example, i would really appreciate more examples of using the EasySave3 Autosave feature, specifically with saving instantiated game-objects with multiple variables. The main reason im writing this, is that it seems that the example provided here doesnt seem to use the Autosave prefabs at all and instead uses the prefabmanager from the easysave2 example. The instantiated prefabs are also the ones from the easy save 2 example
User avatar
Joel
Moodkie Staff
Posts: 4986
Joined: Wed Nov 07, 2012 10:32 pm

Re: Save and Load Prefab Instances using Auto Save

Post by Joel »

Hi there,

Thanks for letting us know. It looks like we uploaded the wrong example. I've just updated the attachment so it should be the correct one.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
User avatar
Joel
Moodkie Staff
Posts: 4986
Joined: Wed Nov 07, 2012 10:32 pm

Re: Save and Load Prefab Instances using Auto Save

Post by Joel »

Mephialtes wrote:Is there some reason that the Cylinder Prefabs contain 2 ES3 Prefab components? I'm assuming this was in error and was going to go on about my day. But I figured id bring it up in case others were confused in the future as well.

Thanks for this example though.
This is indeed unintentional. I'll see about getting this fixed.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
tarlan83
Posts: 3
Joined: Mon Jul 26, 2021 5:57 am

Re: Save and Load

Post by tarlan83 »

I hove the following questions:
  • Ist it possible to save private fields without Properties?
  • Why do I need to save Properties if I can Save/Load directly fields?
  • Is there something like OnLoadFinished Event? I don't understand the order of execution of Awake, Start, Load
  • Is it possible that starting a Scene becomes very slow after this Plugin is loaded?
Thanks in advance! :roll:

All the best,
Tarlan
User avatar
Joel
Moodkie Staff
Posts: 4986
Joined: Wed Nov 07, 2012 10:32 pm

Re: Save and Load Prefab Instances using Auto Save

Post by Joel »

Hi there,
Ist it possible to save private fields without Properties?
You can serialize a private field by adding the [SerializeField] attribute to it.
Why do I need to save Properties if I can Save/Load directly fields?
I'm afraid I don't understand what you mean? You can save properties and/or fields.
Is there something like OnLoadFinished Event? I don't understand the order of execution of Awake, Start, Load
You can find information on the order of events in Unity's documentation:
https://docs.unity3d.com/Manual/ExecutionOrder.html
Is it possible that starting a Scene becomes very slow after this Plugin is loaded?
We've had no reports of this. If you're able to replicate this in a new, empty project with a simple scene and send it to me I'm happy to look into it further.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
tarlan83
Posts: 3
Joined: Mon Jul 26, 2021 5:57 am

Re: Save and Load Prefab Instances using Auto Save

Post by tarlan83 »

Thanks for very quick answers!!!

But with
Is there something like OnLoadFinished Event? I don't understand the order of execution of Awake, Start, Load
I mean that I do not understand the execution order of these functions in combination with EasySave3 - Load

Example:
Default value: bool isVisible = false
When I change this state I show or hide some object or recalculate the path
During the game I change the state to true and save
OnAwake everything initialized correctly but after saved data are loaded I'd like to trigger some calculations (e.g. path, position of sun) and I'd like to trigger a sort of RecalculateState function

Thanks in advance!
User avatar
Joel
Moodkie Staff
Posts: 4986
Joined: Wed Nov 07, 2012 10:32 pm

Re: Save and Load Prefab Instances using Auto Save

Post by Joel »

Hi there,

If you want to manually trigger Auto Save you can follow the instructions at the bottom of the Auto Save guide. This will allow you to dictate when it gets called, and thus be able to call code immediately after it's been loaded:

https://docs.moodkie.com/easy-save-3/es ... -from-code

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
Berncat
Posts: 14
Joined: Tue May 26, 2020 12:28 am

Re: Save and Load Prefab Instances using Auto Save

Post by Berncat »

Could we have a more complicated example? I've been using this asset for a long while and have never gotten the hang of the autosave system.

- Prefabs with variables that can be changed at runtime
- Prefabs that inherit from one another / prefab variants
- Prefabs with children with variables changed at runtime
- Maybe a screenshot of these prefabs in the Easy Save window under Auto Save / Prefabs showing how they are setup? All of the ones used are grayed out without any specific settings

The Cylinder Prefab has two ES3 Prefabs on it in this example scene and shows up twice as well.
User avatar
Joel
Moodkie Staff
Posts: 4986
Joined: Wed Nov 07, 2012 10:32 pm

Re: Save and Load Prefab Instances using Auto Save

Post by Joel »

Hi there,

The use cases you've provided require no different Easy Save setup than any other type of scene. You simply select the variables on the Components that you want to be saved and loaded in the Prefabs window. It doesn't matter whether it's a child of a prefab, the variables are changed at runtime or are a prefab variant.

If you are having issues with integrating Auto Save then I'm happy to assist with those issues if you would like to make a new thread in General Discussion.

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