I am looking for a way to instantiate a prefab in every scene without neither putting gameobjects of it in editor nor another gameobject calling the instantiate. Any idea?
The moral: I have a “Cheater” to test my game easily. I want to have it when I want to test the scenes individually via pressing run on a scene.
I have accomplished this by having a method with the attribute [ RuntimeInitializeOnLoadMethod ]. This helped me to trigger a method without having a script inside any scene and then Instantiated the prefab that I want with DontDestroyOnLoad
Get it by making sure it’s in the “Resources” folder, and then using:
GameObject myObject = (GameObject) Resources.Load("<path>");
Here is some info and examples about how to use it: Unity - Scripting API: Resources.Load