The video showed how this component solves DontDestroyOnLoad but didn’t show how it replaces GetInstance. Isn’t that legitimately one of its uses?
To argue for an example: you have various individual animation scripts for different things. But at different points in the game, for different objects, they spawn the same kind of effect. You wouldn’t put an effect prefab directly into them because, arguably, they shouldn’t need to know the specific prefab; just that it needs to spawn, say, an “explode” effect at a certain spot.
The interface would be something like EffectSpawner.GetInstance().ExplodeAt(Vector3)
. And components of that singleton could take care of randomization, audio, particles, pooling, etc, so that the script merely wanting to make an explosion doesn’t need to know how and to manage the performance details.
This doesn’t have to be effects. They could be spawning enemies. Or pickup items. Coins. Anything where various scripts dealing with logic of WHEN to spawn something shouldn’t need to know HOW to spawn a common thing.
What would be the solution for this? (in the context of the shown PersistentObjectSpawner script) Or is that simply not what it’s for?