I am building a 2D sidescroller game in Unity3D.

It's tile-based. To get better performance I divided the level into chunks. I activate these chunks when the player enters 2D Triggers and deactivate it again when he exits the 2d trigger. So I normally only have a max of 2 chunks loaded. This works good BUT I do have some loading stutters of a few frames when I load a new chunk. How can I prevent that from happening?

Thank you!

• It's a difficult problem in Unity because you don't get access to threading. Unity API calls are only allowed on the main thread, which causes this sort of nonsense. – Almo Nov 20 '17 at 15:34
• But does it work? I haven't seen this work properly yet. – Almo Nov 20 '17 at 16:51
• Are your chunks static, or dynamically tiled? I assume you mean that you have multiple Grid objects with your Tilemap layers on each Grid, and the Grids are being instantiated as they come into view, causing the stutter. Is that correct? – Stephan Nov 20 '17 at 17:23
• The complete level is there at the beginning they are devided in several chungs and the corresponding Trigger. I deactivate what is not needed on awake. And when the player reaches the trigger of the next chunk I activate the chunk and as soon as he leaves the other chunk this one gets deactivated. – OneManOnMars Nov 21 '17 at 15:45

If you structure each Chunk as a Grid with multiple child Tilemap layers, you can let them all load at SceneLoad, and let the Camera frustum cull any of them that aren't in view.