Right now in order to save and load references to gameobjects in the scene, I use references to those gameobjects (which is simple ID script, which has a GUID on it).
Those references I save as strings which I write to a xml.
In order to load the references again, I have a manager script, which is basically a dictionary with all gameobjects and their id’s as a key, then based on the loaded id’s I find the gameobjects again.
two questions;
1.Is the correct/best way to save and load a reference to gameobjects in the scene.
2.Is it not a problem to have a HUGE dictionary in the scene which hold a list of all ids en reference objects (at the moment 3500 entries). > Is this performance hit, or should I not worry about that?
Saving and loading references to objects by some GUID is standard, so that’s fine.
Why do you need to hold the references outside of saving and loading though? Your loading system should have two passes, one where it creates every object and another where it rebuilds references between objects. After that, you’re safe to discard that data because the references are rebuilt and the game should resume as normal, no?
What do you mean by this?
I simply use them as a reference to gameobjects that are in the scene, no need to rebuild anything, I just need a reference to a gameobject.
During the scene users can reselect saved gameobjects, or reload materials on certain gameobjects etc, so this dictionary should not be discarded in the scene.