Page 1 of 1

Saving object with many children/grandchildren.

Posted: Mon Jun 26, 2023 7:31 pm
by Rhevules
Hello, I am trying to use Easy Save 3 for my Unity project, which aims to save an object along with all its children, grandchildren, etc. I noticed that when about 12 prefabs are connected together like a staircase (picture below), it seems like the saving process breaks down, and only when it's less than this number does it start working as it should. I am using in by saving it as bytes sending it to database and then load it later in WebGL. The entire hierarchy consists of prefabs that are spawned several times from the Resources folder. Hence, I would like to ask if there's a possibility to save the entire object hierarchy without serializing too much data. If it is possible to spawn specific prefab and adjust, its local rotation, the material of its child, and whether it is active. Sorry if the question is wierd but I tried to look for guides in the documetation and youtube and I am still confused. Thank you for any help.
Code for saving the object:

Code: Select all

public string SaveToBase64()
    {
        string filePath = "temp.es3";
        ES3.Save<GameObject>("myGameObject", mainPrefab, filePath);
        byte[] bytes = ES3.LoadRawBytes(filePath);
        string base64 = Convert.ToBase64String(bytes);
        return base64;
    }
Image

Re: Saving object with many children/grandchildren.

Posted: Tue Jun 27, 2023 8:10 am
by Joel
Hi there,
I noticed that when about 12 prefabs are connected together like a staircase (picture below), it seems like the saving process breaks down
There's a serialization depth setting which could potentially cause this (Tools > Easy Save 3 > Settings > Advanced Settings > Serialization Depth), in which case increasing it should resolve the issue. However, it sounds like you don't actually want to save the children per se (see below).
If it is possible to spawn specific prefab and adjust, its local rotation, the material of its child, and whether it is active. Sorry if the question is wierd but I tried to look for guides in the documetation and youtube and I am still confused.
If you want to save a prefab but not save anything about it's children, you can do so by disabling Save GameObject Children in Tools > Easy Save 3 > Settings. The children will still be spawned as they're part of the prefab, but they will keep their default values as nothing about them will be loaded.

All the best,
Joel

Re: Saving object with many children/grandchildren.

Posted: Tue Jun 27, 2023 8:38 am
by Rhevules
At first it didn't work, but later when I increased the depth to a fairly high value, everything seems to be working. For now, I will leave this solution and in time I will replace it with the other method. Thank you very much.