Save and Load Prefab Instances using Auto Save

Examples which use the ES3AutoSave and ES3Prefab Components, which do not require code.
Post Reply
User avatar
Joel
Moodkie Staff
Posts: 3723
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
Save and Load Prefabs Instantiated at Runtime using Auto Save.unitypackage
(51.08 KiB) Downloaded 1114 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: 3723
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: 3723
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: 3723
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: 3723
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

Post Reply