Page 1 of 1

Save only Transform and Material from Prefab

Posted: Sun Jan 22, 2023 3:17 pm
by noob_vulcan
Hi,

I am currently saving prefabs via ES3 Prefab script on them. It saves everything which I don't want thus increasing the file size.

Is there a way to select what I want to save like Transform and Renderer Info?

Re: Save only Transform and Material from Prefab

Posted: Mon Jan 23, 2023 10:24 am
by Joel
Hi there,

The easiest way to do this is to go to Tools > Easy Save 3 > Auto Save > Prefabs, select the Components you want saved on the prefab from there, and set the Save Event and Load Event to None at the top of the window.

When you call ES3.Save on the prefab using code
it will acknowledge what you've selected in the Auto Save window, and because you've set the events to None, Auto Save will not be called.

All the best,
Joel

Re: Save only Transform and Material from Prefab

Posted: Mon Jan 23, 2023 12:58 pm
by noob_vulcan
Hi,

Thank you for the reply. Is there another way? because this way is not feasible for my project.

I am working on world building game where users can spawn different objects and create a scene and save it. So as of now I have around 150 different objects and selecting Components from the window is not feasible, because there is a lot of human error possibility.

Current Save Process -
1. All prefabs have ES3 Prefab component on them.
2. A Save manager class that has a list of prefabs that are instantiated
3. I'm saving this list in a file via
var newSaveFile = new ES3File("UserWorlds/" + loadedSceneInfo.fileName);
newSaveFile.Save<List<GameObject>>("prefabList", prefabInstances);
newSaveFile.Sync();
I only need to save Transform and Renderer Info(For Material) for all these objects. Is there a better way to do this?

Thanks,
Vineet

Re: Save only Transform and Material from Prefab

Posted: Mon Jan 23, 2023 1:51 pm
by Joel
Hi Vineet,

You can programmatically add an ES3AutoSave Component and assign the Components want to save to the ES3AutoSave Component's 'componentsToSave' field.

All the best,
Joel