So I have two levels divided by a door. I’m keeping the second level hidden while the player plays through the first area, then as the door opens I’m turning on the second level just before the player enters it.
As soon as I switch the second level on, I get a huge spike in rendering time for one frame, and then it calms down and runs normally. I’m trying to find a way to get rid of this big hitch.
I’ve tried a number of ways of hiding the levels:
Deactivating game objects causes an even worse spike as calling OnEnable on numerous objects tends to be costly
Turning off all of the renderers in the scene actually works better than deactivating the root object, I still have this spike in render time though
Set each level to have a unique layer, then adjust the culling mask of my main camera. I thought this might help because I’m not activating/deactivating any components, but nope.
Unfortunately using “portals” and occlusion culling won’t work for me since I’m building these levels proceduraly.
Any ideas what is causing this super long frame and how to fix it? The bigger the scene I am transitioning to the worse the spike. Even on PC for a large scene I’ll have one frame that takes 600 ms to render the scene, then it drops down to ~5 ms next frame.
Thanks for your help!