Saving modified prefabs

Discussion and help for Easy Save 3
Post Reply
User avatar
TauCetiLabs
Posts: 8
Joined: Mon Dec 28, 2020 2:31 pm

Saving modified prefabs

Post by TauCetiLabs »

When I saw that prefabs could be saved in ES3, I was sold, as we use the prefab workflow to drastically simplify development. However, saving just the changes to a prefab doesn't seem to be as turnkey as I had hoped.

As a first test, I am trying to save a modified prefab to a file which has just three overrides (1 transform in SiloSite, 1 boolean in MoonSurfacePlacable and 1 reference in CeramicBuffer):
SiloPrefabOverrides.PNG
SiloPrefabOverrides.PNG (11.39 KiB) Viewed 1364 times
The only way I have found to save the prefab is using this code, which saves the entire GameObject and references, creating a 128kb file for essentially 3 pieces of data.

Code: Select all

public class SaveLoadTester : MonoBehaviour
{
    public float SaveTime = 5;

    public float LoadTime = 10;

    public bool saved = false;
    public bool loaded = false;

    public GameObject Prefab;

    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        if (!saved && Time.time > SaveTime)
        {
            saved = true;

            ES3.DeleteFile("Test/Testing.lbs");
            ES3.Save("Test", Prefab, "Test/Testing.lbs");
        }

        if (!loaded && Time.time > LoadTime)
        {
            loaded = true;
            //test loading stuff here
        }
    }
}
The prefab does have an 'ES3Prefab' component attached to the prefab base, but saving a Transform, or ES3Prefab using the ES3.Save("Test", Prefab, "Test/Testing.lbs") only saves the changes on the component level.
Reference Manager.PNG
Reference Manager.PNG (16.49 KiB) Viewed 1357 times
What am I missing here?

Also, the ES3ReferenceManager in our main scene generates over 70k references. Is there any way to tell it to 'ignore' most of those, as the vast majority are 'static' references loaded with the scene?
User avatar
Joel
Moodkie Staff
Posts: 4849
Joined: Wed Nov 07, 2012 10:32 pm

Re: Saving modified prefabs

Post by Joel »

Hi there,

In your code you're asking Easy Save to store the entire GameObject, which is why you're getting the 128kb file. If you only want to store specific aspects of your prefab, you should only save the variables or Components which require saving rather than the entire GameObject.

Regarding the ES3ReferenceMgr, this maintains references to everything which is referenced by your scene (i.e. everything which could possibly be saved) so that we can create persistent reference ID. You can manually manage the reference manager by going to Window > Easy Save 3 > Settings, uncheck 'Auto Update References', and then delete your Easy Save 3 Manager to allow it to be regenerated. If you need to save a reference to something, you will need to right-click it and select Easy Save 3 > Add Reference(s) to Manager.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
User avatar
TauCetiLabs
Posts: 8
Joined: Mon Dec 28, 2020 2:31 pm

Re: Saving modified prefabs

Post by TauCetiLabs »

Thank you for the quick response. Light bulb finally went off in my head as to how ES3 is meant to be used on the developer side. I'm likely to have more questions, but we are happy with this solution so far.

You rock Joel!
User avatar
Joel
Moodkie Staff
Posts: 4849
Joined: Wed Nov 07, 2012 10:32 pm

Re: Saving modified prefabs

Post by Joel »

Glad to hear it, feel free to ask away with any other questions you have, it's what I'm here for :)

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