What if we want to have objects that can be either spawned by a spawner and added to scene in editor view?
I will use an example of EnemyPrefab & EnemyController.cs here.
What I want requires of course the SaveableEntity component for the EnemyPrefab, so the SavingManager will save all build-in enemies on scene that where added in editor. Then we need a Spawner to save all the enemies that it spawns or a controller that will search for all object with EnemyController.cs. But there will be a collision / problem with saving single enemy twice - by SavingManager (becouse prefab must have a SaveableEntity and SavingManager will always capture it) and by spawner/controller (becouse we want to have spawned enemies also).
I’ve come up with an option to solve it, but it doesn’t sound like a best sollution, so I hope for some other solutions
Potential Solution: Create prefab variant of EnemyPrefab called for eg. “EnemyPrefabSaveableEntity” that will have SavebaleEntity component attached. The first prefab can’t have SaveableEntity. When you add an enemy on the scen then you use second prefab with SaveableEntity, when you’re adding enemy prefab for spawner then you use the normal prifab, not the variant. The problem with this way is to always remeber to use proper prefab when adding to scene and when adding in inspector for spawner.
Also I was thinking about allowing the scripts to create UUIDs in the runtime and then use other scripts to save/load the objects that were spawned and the SavingManager will ignore them (eg. if the prefab implements the IEnemy interface, then SavingManager will ignore it or pass the save/load to the proper script or something like that). But I’m less concerned about this solution than the previous one.