Field referencing other GameObject is null when loaded
Posted: Sat Aug 10, 2019 3:21 pm
I've made some progress using ES3 to save my game. There are several references between game objects in my scene which complicates things.
One thing I noticed is that if a GameObject A with Component 1 has a reference to a GameObject B that is lower in the scene (which means it will be saved after), then when I load the Save Data and the GameObject A is loaded and Component 1's fields are being read and populated, it won't find the reference for GameObject B since it hasn't loaded yet.
Am I seeing expected behaviour here? Is there something I can do to fix that problem? Perhaps have ES3 instantiate an empty Game Object when Component 1 tries to find the reference to Game Object B and then when the ES3 reader gets to the part in the Save File where Game Object B is loaded, it would populated components and fields on the empty GameObject which was instantiated earlier.
Any help is appreciated. Thanks!
Fred
One thing I noticed is that if a GameObject A with Component 1 has a reference to a GameObject B that is lower in the scene (which means it will be saved after), then when I load the Save Data and the GameObject A is loaded and Component 1's fields are being read and populated, it won't find the reference for GameObject B since it hasn't loaded yet.
Am I seeing expected behaviour here? Is there something I can do to fix that problem? Perhaps have ES3 instantiate an empty Game Object when Component 1 tries to find the reference to Game Object B and then when the ES3 reader gets to the part in the Save File where Game Object B is loaded, it would populated components and fields on the empty GameObject which was instantiated earlier.
Any help is appreciated. Thanks!
Fred