Saving Children and Changing GameObject Save Type

Discussion and help for Easy Save 3
Post Reply
vikramapilla
Posts: 8
Joined: Thu Mar 03, 2022 8:16 pm

Saving Children and Changing GameObject Save Type

Post by vikramapilla »

Hi Joel,

I have two questions regarding saving a game object and its children. I already used the ES3.Save<GameObject>(), it works very well to save including the children components. However, I faced two issues while using this method.
  1. When I saved >150 game objects, the save was pretty slow, even when using cache. I assume it probably stems from saving mesh data. However, I do not require the mesh data to be saved. Could you please share - how I can save the entire game object without saving the mesh or any other particular component?

    I could save individual components, but I am looking for a way where a single line such as ES3.Save<GameObject>() would work
    ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  2. Similar to ES3.Save<GameObject>, which saves including the children's objects - how can I realise this for other types. For example, if I want to save ES3.Save<Collider>, can it save the colliders in the children too? If not, do you suggest a way of doing this?
User avatar
Joel
Moodkie Staff
Posts: 4849
Joined: Wed Nov 07, 2012 10:32 pm

Re: Saving Children and Changing GameObject Save Type

Post by Joel »

Hi there, and thanks for getting in contact.

Meshes aren’t saved by reference in this circumstance, so this is unlikely to be the issue. The issue is more likely that GameObjects are simply complex objects with deep hierarchies, much of which doesn’t need to be saved.

In this case the only solution would be to save less data. I.e. only save the Components/fields of your GameObjects which change at runtime and need to be persisted, rather than the entire GameObject.

One way you can do this is to enable Auto Save for your scene (Tools > Easy Save 3 > Auto Save), set the Save and Load event to None, and then select which Components you need to be saved for each GameObject or prefab. When you call ES3.Save, it will use these Auto Save settings but Auto Save will otherwise be disabled.

Regarding your second question, you would need to find the parent and child Components yourself, put them into a List and save/load this. Components don’t have children in Unity, only GameObjects (or more specifically their Transforms).

All the best,
Joel

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
vikramapilla
Posts: 8
Joined: Thu Mar 03, 2022 8:16 pm

Re: Saving Children and Changing GameObject Save Type

Post by vikramapilla »

Thanks for your answer, Joel. Appreciate the quick answer.

Is there a way I can save selected components/fields without using AutoSave? I am looking for a save type that can ignore certain components.

For example, if I choose to save a game object, then all of its children must be saved, however, it should ignore certain components - mesh, collider, etc.

I am looking for a solution where I can change the save type script of the GameObject and use a single line ES3.Save<GameObject>(). This should then save the entire hierarchy of a game object and also the components ignoring mesh, collider, etc.
User avatar
Joel
Moodkie Staff
Posts: 4849
Joined: Wed Nov 07, 2012 10:32 pm

Re: Saving Children and Changing GameObject Save Type

Post by Joel »

Hi there,

The solution I proposed only uses Auto Save to select the Components you want to be saved (this is why we disable the Save and Load event of Auto Save). You still call ES3.Save and ES3.Load yourself; Auto Save won’t automatically save anything.

Otherwise you would need to manually save each Component and field of each GameObject yourself.

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