Loading objects that refer to each other

Discussion and help for Easy Save 3
Post Reply
Anma.wp
Posts: 2
Joined: Thu May 25, 2023 8:31 pm

Loading objects that refer to each other

Post by Anma.wp »

I have runtime instantiated Prefabs whose components can have references to each other. When objects have been loaded some of this references is null.

As far as I understand the problem is that referenced components doesn't exist in time when current component is deserializing.
However I don't see a solution to the problem. Is it possible to deserialize objects fields after instantiating all GameObjects and their components?

All prefabs has enabled ES3Prefab component. I tried use auto save and tried manually save list of objects.
User avatar
Joel
Moodkie Staff
Posts: 4899
Joined: Wed Nov 07, 2012 10:32 pm

Re: Loading objects that refer to each other

Post by Joel »

Hi there,

The simplest solution to this is to load twice. Once to load the objects, and again to load the cross-references.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
Anma.wp
Posts: 2
Joined: Thu May 25, 2023 8:31 pm

Re: Loading objects that refer to each other

Post by Anma.wp »

Joel wrote: Fri May 26, 2023 7:39 am Hi there,

The simplest solution to this is to load twice. Once to load the objects, and again to load the cross-references.

All the best,
Joel
Yep, it works. Thank you.
Post Reply