Hello,
I know, this is an old one, and that it is how Unity works … But I’m starting to hit a big wall in regard of framework optimisation because of this restriction.
For example :
-
In case of Additive level loading, I am forced to run a script in each level that scans for duplicated system objects and cleans any unnecessary clone (like the “core” gameobject which hosts the MVC controller). It also forces me to graduate my system functions deployment, so that there is no conflict due to these duplications. Huge pain in the ass …
-
In case of system protection (routines that scans if everything is ok database wise), it forces me to write a flag on a DontDestroyOnLoad object at Application Start which tells that I don’t need to run that test at each new level. Kind of overkill …
-
In some way, it forces to use Additive Level Loading, so that you need to load an empty scene at start, with DontDestroyOnLoad persistant system objects that would deploy all the game views. This is the most annoying part to be honest, as it forces any game testing to start from that empty scene. I can’t pick a scene, hit play, and tadam everything is ok. I have to play that empty system scene each time, and create an interface to load any random scene. Overkill once again …
-
It also force to expose those system objects. Even with creating a non MonoBehaviour class inside these, they’re still instanciated in a public gameObject, or we have to use static functions, which is not that optimal either.
If there was a way to launch a script without it needing to be attached to a gameobject, we could save a lot of clunky coding workflows for sure.
With Unity being used by big AAA studios, I don’t understand why any of them had complained about that yet ?
Flash forced me to use the same empty system scene logic back when I coded games for a very security sensitive business (national lottery). And it felt very awkward, unnatural, and unappropriate for any “serious” framework.
Long story short, is there any alternate way to load a persistent script without attaching to a gameobject ? Or any plan from Unity to create such capability ?
edit : Plus I guess it wouldn’t be hard to implement at all, like the matter of an hour : just insert a unique, invisible, static and persistent MonoBehaviour at the start of any Application, that could be overriden by the coder.