I’m currently looking into building an application which uses several scenes as different sections of the app, which are switched at appropriate moments within the run of a single app.
When switching from, let’s assume scene A to B, a significant freeze occurs on loading the second scene. I know this can be worked around using SceneManager.LoadSceneAsync(…), and making sure scene B is ready at the time the user performs a specific action (holding off using AsyncOperation.allowSceneActivation). This reduces the freeze time to practically zero, and that’s good.
However, for my situation, I want the user to be able to go back to scene A, select a different “item”, and display said item in scene B again. This currently unloads scene B, reloads scene A, and prepares scene B again, just to unload A when the user performs an action. It seems incredibly redundant.
I wonder if there is a way to revert a scene to the state where it’s waiting for the user to perform an action. Such as, the scene is deactivated in the app, but not unloaded, in case the user wants to re-instantiate it. Does anyone have an idea regarding this conundrum?
I’m looking into a similar use case. e.g. we have a multi-scene game, 2 scenes alternate e.g. map/strategy gameloop has its own scene and battle has its own scene.
We have found that unloading the map scene takes a long time for some reason (loads fast though) and doesn’t seem to be async dispite using the unload async call. So our idea was to simply leave it loaded but of course we need to disable its objects.
It would be greate if we could simply deactivate the scene leavign it in memmory but ignoring its objects till re-activated but I suppose worst case we could root all elements in the scene under a single gameobject and simply disable that to get the same effect … seems unnessisary though.
Anyone done similar before?
Better yet any ideas why a scene would load from scratch fast but take forever to unload … more over it locks the machine up for a few seconds nearly a min in some cases and yes that is with the unload async. We do a good bit of load and unload with additive scenes and this is the only case where we have seen this massive lag with an unload.
No we worked around the issue
For gameplay we just disable the root object as opposed to unload the scene in question
For returning to main menu we found it was faster if we went in and manually destroyed any objects that where spawned in during gameplay. … so basicly just call destroy on the same GO we disbale when toggle between map and combat
Any progress on this? I don’t really like the root gameobject approach and I’m not sure if it has the same effect as an hypothetical “disabled scene but still loaded” scene, performancewise.
It’d be useful to be able to keep multiple scenes loaded, ready to activate at will. Although I’d be fine if someone confirmed that the root gameobject approach is effectively the same as what we’re asking.
As far as I know, there’s no such thing as making a scene active or inactive (There is such a thing as the “active” scene but it does not mean the same thing as we’re talking about here). So yeah, you have to somehow activate or inactivate game objects.
Once your game objects are initialized and running, there is no more effective way than having all root objects of the scene activated/inactivated. Retain state of root game objects before setting them all to inactive to “inactivate” scene and properly restore them when “reactivating” scene content.