- Home /
How to manage scene-specific prefabs with a Singleton controller?
I have a singleton game controller prefab and I've been creating a couple of levels by nesting other prefabs inside an InteriorManager
object (which is a child of said game controller).
When testing individual scenes this seems fine. However, when travelling from scene to scene, the "local" game controller gets replaced with the previous one. I'm aware this is due to the singleton pattern.
What is the best solution to have the correct area objects available as the player travels through scenes?
a) Keeping all areas inside the singleton and activating/deactivating them depending on the room? I decided against it since it seemed unwieldy and a hierarchy bloat, it'll also get confusing.
b) Have a prefab instance library to load from whenever a scene loads? I decided against this one because it seems to run against Unity's visual approach to level design.
c) During the singleton pattern replacement step, iterate through "relevant" children and move them to the singleton object (change their transform from the local game controller to the singleton game controller)?
d) Implement Unity-specific smart object "merge" I might not be aware of?
e) Something else entirely? Perhaps this hierarchy structure is the wrong way to go for something like this. Thanks.
Your answer
![](https://koobas.hobune.stream/wayback/20220612223138im_/https://answers.unity.com/themes/thub/images/avi.jpg)