Page 1 of 1

Auto-save not loading references created at runtime ?

Posted: Thu Mar 09, 2023 10:25 pm
by kasspip
First, great package, I'm loving it !

But I struggle with one point, even after reading the guide and playing with your exemple package so I feel stupid asking help for this trivial senario.

1- I use the auto-save method, I have a manager gameobject instanting a prefab at runtime.
2- It stores the reference of the spawned prefab's instance.
3- I save the scene and exit.
4- I check the save file, the manager has correctly saved a "_ES3Ref" with the ID of the spawned instance, and the instance saved data is also described below it.
5- I load the scene : the saved prefab is correctly loaded as well as all variables of the manager exept for that reference which is null !

What I am missing ?
Thanks

Re: Auto-save not loading references created at runtime ?

Posted: Fri Mar 10, 2023 8:24 am
by Joel
Hi there,

This is likely because the GameObject containing the reference to the prefab instance is loaded before the prefab instance. In this case loading twice should allow the reference to be loaded.

You can manually trigger Auto Save to load twice from a script by calling ES3AutoSaveMgr.Current.Load() twice. It’s recommended to set the Save Event and Load Event to None when manually triggering Auto Save from code also. Let me know if you need any help with this.

All the best,
Joel

Re: Auto-save not loading references created at runtime ?

Posted: Fri Mar 10, 2023 9:50 am
by kasspip
That was it !
I set auto-save events to none and called manually ES3AutoSaveMgr.Current.Save() and ES3AutoSaveMgr.Current.Load() twice and it's now working as expected.

Thank you for your support !