Freezing problem while creating game


There are 10 rooms in our game
All the rooms are closed
We activate 1 of the rooms randomly with a code.
But the game freezes for 1 second while the rooms are being created.
The materials inside the rooms are in picture 1
There is an average of 20 materials for each room.
How can I fix the freezing problem?

You can try to preload all rooms out of sight, and then move them to the player when needed instead of enable and disable, that may allow them to stay in memory. If you donā€™t want all to stay in memory you can preselect the next room and have it load while the player finishes the current room.


It also depends on the setup for the rooms, whether assets are preloaded or not.

Normally the freeze is due to shader compilation (especially if lights are involved), textures being uploaded to the GPU and physics mesh colliders being created.

1 Like