Hello everyone,
I would to know 2 things:
-
When I load my main scene with load async function, it takes 45 seconds approximatly. But when I return to the main menu (without leave the game) and load async again my main scene. It takes less than 10 seconds.
-
When I’m in my main scene I have several 3D objects. When I move my camera in 360 degree to look every element around I have a lag spike in the profiler at 20fps. After that everything is ok and stay at 60fps. Same thing like the load async, if I go back to the main menu, reload that main scene and move camera, I have no lag.
Why? Unity keep in memory something?
How to avoid this long time loading when I load async for the first time and avoid lag when I look the 3D objects for the first time?
Thank you 
Best regards,
Alexandre
Hi there,
Unless you specify otherwise in your loading ops, unity doesn’t trigger a Resource.UnloadUnusedAssets after a scene was unloaded, but only one before the unload, if it is a destructive load/unload (I.e. non Async, non additive).
So in your case, I guess the assets/resources used in the two scenes stay in memory as you load between them. The scene structure itself is unloaded and needs reloading but that’s usually not the heaviest part of the loading operation.
As for the hitches on first looking around, I suspect that the cause for that is that the shaders/materials for some Objects aren’t part of what you first see, or prewarmed, i.e. they are loaded in memory but not yet uploaded to the GPU. You can hide this under a loading screen fade by just making sure one object of every shader is in Camera view in a first frame, but Hidden under the fade, or by using APIs to warmup these shaders, e.g. via: