SaveableEntity design decisions

If I’m understanding what this class (SaveableEntity) does, it seems to do two main things
a) saves and loads components we want to save (i.e. ISaveable) on gameobjects we want to save. It does this during gameplay
b) it generates unique identifiers while we are editing our scene (but doesn’t generate unique IDs for game objects are spawned/instantiated during play)

Is this right? These two tasks seem unrelated and just want to do a reality check here. I may have follow up questions after that.

I’m also curious - where does the persistence for our static Dictionary member variable live if it gets updated during edit mode and lasts between scenes? Does it ever get wiped / What actions trigger it getting cleared out?

Yep.

Also correct, if the SaveableEntities in the scene have no identifier, or multiple entities have the same identifier.

Static variables simply exist. They are not tied to a particular object or instance. They actually are reset when you see a Reloading Domain message. They actually don’t survive pressing the Play button (but once the game starts, the Dictionary is rebuilt when you press stop in the game. An exception to that is if you have the Enter Play Mode Settings checked in Project Settings | Editor and Reload Domain Unchecked. If you do that, however, then you’ll have trouble with the Persistent Objects Prefab between scenes, so um… don’t do that.

I was curious if we end up changing this class’s design as we progress and add functionality? I’ve heard of editor scripts and I even downloaded a few to help improve my editor usability. The editor functionality and game play functionality seem like they should be distinct. I have to imagine this is a temporary condition and that this class will change as we add the planned features.

Thanks. Yeah definitely familiar with static variables but honestly never seen an example where their values exist in (seemingly) uncompiled code! This now makes it clear why Unity does a domain reloads after I change the code and again when I press play even if I changed nothing.

Privacy & Terms