Page 1 of 1

Loading objects that refer to each other

Posted: Thu May 25, 2023 9:55 pm
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.

Re: Loading objects that refer to each other

Posted: Fri May 26, 2023 7:39 am
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

Re: Loading objects that refer to each other

Posted: Sat May 27, 2023 8:39 am
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.