So, let me start off by saying that I don’t really understand the mechanics behind SceneManager.LoadSceneAsync, only that it seems to work well for a loading screen.
See, in my project, every tree, rock and all but a handful of cities are spawned by the server, and sent to the client to be spawned when they connect. This means at least 2000 objects that need to be instantiated and run their own attached scripts.
As it is, those object get created, 5-10 objects per frame, after the character has been spawned and can be controlled. This means that the player gets exposed to framerates of 30fps and lower. Obviously, this is not ideal.
I do have a loading screen, using the following script to transition
I don’t know how I’d be able to spawn the objects during this loading scene, into the new scene that is about to be activated, without them being removed when the loading scene objects are destroyed.
You use an event call to control when to activate the scene.
You’d have that coroutine listen to a static event and set allow scene activation to false. then in the scene some GameObject with a LoadManager Script loads in objects via Awake (which should fire even the scene is not activated as long as the GameObject itself is spawned enabled) once the load manager finishes instantiating objects it invokes that static event, at which point the listening Coroutine can set allowSceneActivation to true.
That’ll basically work, depending on how you are accessing the objectLoader instance. not sure how you are accessing that instance which is why I mentioned static events.
as long as you’re instantiating them into the new scene and not the “DontDestroyOnLoad” scene or whichever sub-scene is running that coroutine.
Scene activation basically takes those objects out of stasis (they’re created, but things like Update(), physics, audio, etc. won’t run until the scene activates), it has nothing to do with removing them (unless you have code that would remove them)