Page 1 of 1

How to detect when loading is done?

Posted: Sat Sep 03, 2022 1:16 am
by newjohnny
I'm getting numerous null references from instantiated prefabs referencing each other so I would like to do a 2nd load pass, as suggested in other threads. I'm using the code below to load. How can I detect when this first load is finished?

Code: Select all

ES3AutoSaveMgr.Current.settings.path = file;
ES3AutoSaveMgr.Current.Load();

Re: How to detect when loading is done?

Posted: Sat Sep 03, 2022 6:57 am
by Joel
Hi there,

Loading happens synchronously, so it’s finished immediately after the Load call is made.

All the best,
Joel

Re: How to detect when loading is done?

Posted: Sat Sep 03, 2022 7:41 am
by newjohnny
Ok good to know, however my scene takes about 10 seconds to load because it's huge and not fully optimized yet. Would two load commands still fully process in this scenario?

Re: How to detect when loading is done?

Posted: Sat Sep 03, 2022 8:08 am
by Joel
Hi there,

As they’re synchronous they will still process. The second won’t ever start until the first has completed.

All the best,
Joel

Re: How to detect when loading is done?

Posted: Thu Aug 10, 2023 5:01 pm
by Tanoshimi
(Bumping this, instead of creating a new thread)

I'm having a similar issue, but I'm using AutoSave. It's set to load the scene in the Awake() function, but when I try to access the object's it's loading in the Start() function, I see they have not been instantiated yet. This doesn't happen often, maybe 1 in 10 times, but since my code checks to see if the objects exist and then creates them from scratch if they don't this is causing all of my saved data to be reset with default data at random intervals.

Is there a way to check to see if the AutoSave load is done? Or wait until it is? I mean, I can check to see if my GameObject is null, but I'm looking for a best practice here.

Currently, I plan on checking if the object is null, and if it is, checking to see if there's a save file. If there is, we can assume it hasn't finished loading. If there isn't, then we can assume this is the first run or the player deleted the file to reset the game.

Any suggestions?

Re: How to detect when loading is done?

Posted: Thu Aug 10, 2023 6:43 pm
by Joel
Hi there,

As mentioned above, Easy Save works synchronously (unless you call it from your own thread), so it's done immediately after it's called. As all Awake() methods are called before any Start() methods, it would indicate that the issue isn't to do with timing but something else.

If it helps, you can manually call Easy Save using the code here:
https://docs.moodkie.com/easy-save-3/es ... -from-code

Easy Save will be finished on the line of code immediately after you call Auto Save's Save() or Load() method.

All the best,
Joel

Re: How to detect when loading is done?

Posted: Fri Aug 11, 2023 12:10 am
by Tanoshimi
So I wasn't sure if Start could run before all of Awake finished, I thought it would go as soon as Awake finished initiating commands. Good to know.

It appears that somewhere, sometime, it's saving after my data structure has destroyed the object, so it's not saving any data, then the next time there's no data to load.

At least, that's what I think is happening, because every time it happens I look at the save file and it's missing that chunk. I'll research it more. But it's hard to trace because it doesn't happen every time.