Example needed for saving a scene

Easy Save 2 has been replaced by Easy Save 3, so is no longer supported.
outofspace
Posts: 36
Joined: Wed Jul 03, 2013 7:28 am

Example needed for saving a scene

Post by outofspace »

Hi Joel,

Can you make a simple Example of saving/loading a scene that has a few custom components, and in each of these component there are List<GameObject> that references other gameObjects in the scene? These gameObjects could be cubes and these cubes are in a Hierarchical structure. This example is typical of what a typical unity scene would look like. Currently most of the examples are essentially saving assets or properties of assets and not really demonstrating how we can use EasySave in the context of a Unity Scene.

Thanks. Please answer this topic, I've been waiting over 48 hrs since my first question and still no reply.
User avatar
Joel
Moodkie Staff
Posts: 4849
Joined: Wed Nov 07, 2012 10:32 pm

Re: Example needed for saving a scene

Post by Joel »

Hello outofspace,

Saturday and Sunday are not working days here in the UK, and your first message was sent after working hours on Friday.

There are a number of ways in which you can achieve this. The easiest way is to give each GameObject a unique name, including objects in a hierarchy. Then you can just compare the name to those in a list of GameObjects and load the data to the appropriate variables in that GameObject.

For objects instantiated at runtime it requires a bit more work, but generally it is good form to instantiate a prefab which already has the structure you are looking for, like in this example.

If this is not an option, and ensuring that each parent has a unique name, you could save the name of the parent with each set of data you save. Then simply go through the List of GameObjects until you find the parent, and then set that object as the parent :)

Edit: We'll also arrange for an example of this to be included in a future update of Easy Save.

Regards,
Joel
outofspace
Posts: 36
Joined: Wed Jul 03, 2013 7:28 am

Re: Example needed for saving a scene

Post by outofspace »

Can I ask a favor.. Is it possible to have the example somewhere so I can download it instead of waiting a long time for the next update.
I want to try out your suggestion to learn how EasySave works for this kind of situation.

Would really help me and potential users if we have an example for each of the scenario that you mentioned. Because these are real world use-cases that affect the majority of people.
User avatar
Joel
Moodkie Staff
Posts: 4849
Joined: Wed Nov 07, 2012 10:32 pm

Re: Example needed for saving a scene

Post by Joel »

We'll post the example in the Examples forum as soon as it's finished. I'll move it up our To Do list for you so that hopefully we'll have it done by the end of the day.

All the best,
Joel
outofspace
Posts: 36
Joined: Wed Jul 03, 2013 7:28 am

Re: Example needed for saving a scene

Post by outofspace »

Thank you Very Much !
Cheers.
User avatar
Joel
Moodkie Staff
Posts: 4849
Joined: Wed Nov 07, 2012 10:32 pm

Re: Example needed for saving a scene

Post by Joel »

We've created an example here which allows you to specify a unique ID, and works for both child and parent objects HERE.

We'll also create an example for instantiated objects, but this will take a while longer as there are other example requests we need to complete first. This will basically be a mix between the example we've just created, and THIS example with a Prefab Manager class.

All the best,
Joel
outofspace
Posts: 36
Joined: Wed Jul 03, 2013 7:28 am

Re: Example needed for saving a scene

Post by outofspace »

Hey Joel,

I noticed that one of the reasons that it's so hard to handle the hierarchy with EasySave is that fact that there's no hierarchy information being saved. Most of what is being saved are individual data items. Unity's paradigm is really built on the Scene Hierarchy and if this information is not persisted, then it's very hard to rebuilt the scene. Currently, when restoring a GO that has been deleted in the scene, we have to first load it into the scene together with it's parent's ID or name, then use Find() to look for the parent transform then attach. This process has to rely on the scene hierarchy because it does not have its own scene graph.

Perhaps the situation would be much simpler if EasySave keeps track of the objects with some sort of scene graph data of its own. This will make restoring the scene much easier because as the unity scene hierarchy comes and go, we still have the relationships between the individual objects. Each time something is saved, the Scene Graph is updated. If each GO had a uniqueId, an associated prefab, and each component within the prefab had save()/Load() functions, then restoring with the scene graph data is quite simple.

There are also many advantages to having this Scene Graph:
1. It can be used to store additional meta-data about the stored objects.
2. We can also query the graph to get useful information about the saved objects without having to load the object into the scene.
3. Selectively restore a part of the graph.

The best scenario is to get access to the GO like they were all in the scene. Ex: Find(), FindChildren(), getParent(), etc...
User avatar
Joel
Moodkie Staff
Posts: 4849
Joined: Wed Nov 07, 2012 10:32 pm

Re: Example needed for saving a scene

Post by Joel »

We'll add hierarchical information to the To Do list, and if there's demand for it, we'll implement it. However, this is the first time that anyone has requested it as most people don't require it, and those who do implement it by saving the unique parent ID with the data and searching a list.

All the best,
Joel
outofspace
Posts: 36
Joined: Wed Jul 03, 2013 7:28 am

Re: Example needed for saving a scene

Post by outofspace »

Please let me know when you finish the example as I cannot really see how to best achieve this with EasySave.

Thanks.
outofspace
Posts: 36
Joined: Wed Jul 03, 2013 7:28 am

Re: Example needed for saving a scene

Post by outofspace »

Ok, I got the example and have been trying to implement in a real project.

Maybe you can explain a bit more about the example.

I have an Prefab that has has about 3 levels and a total of 10 child Game Objects. Each one of these child Game Objects have attributes that needs to be Saved and Loaded. Can you help with how the example works in this situation. I'm really not seeing how the example works in a real project.

Thanks.
Locked