I’m not sure how you got your code but it doesn’t do anything useful. Every frame, it goes through all root objects in the Dungeon scene and tries to load an asset with the same name from the Resources folder. This does not tell you how long it took to load the scene object (there’s no way to get that information from Unity) and since it’s part of Update
, it will execute every frame and continue forever.
This code is causing its own issue and your original problem is somewhere else. Try to simplify your loading to isolate which part of your code is causing it. You might also want to look with Unity’s memory profiler – this is the proper way to see which objects are loaded in memory. But this might be difficult if your issue happens during loading, you might have to find and fix that issue first before you can use the memory profiler.