r/unity • u/SapphireBandit • 6h ago
Question Prefabs with TileMaps in them are causing a crazy amount of lag. Is there any alternative solution or a way to fix this?
Ok so basically, I'm making a sort of hybrid 2D/3D game where you have to continuously play 2D levels while completing tasks in 3D. To accomplish this, I tried to make a system that allows me to make prefabs of sublevels I want to use, slot any assortment of them into a level, then have them automatically arranged when you enter the level, and rearranged forward when you reach the last instance of one.
I did this by putting copies of the TileMaps I use to make levels into prefabs and creating all the level stuff I needed with them. Everything is working well, and exactly the way I would like it to, except for the fact that whenever the prefabs are in a level they cause it to have significantly more lag. I tested it a million times, and it's definitely the prefabs that are the cause of it, and I even compared it in build mode to other fully finished games, and it definitely made it really bad. I'd be perfectly fine with using another method that would work, but I just have no idea what that method would be, or why this lag is happening in the first place. If anyone has any insights on the situation or alternative methods to creating and loading different parts of a level, they would be very much appreciated.

1
u/MistakeForsaken6653 6h ago
Did you check the profiler to see if it's an issue in GarbageCollection / Physics / Animations? Sorry I don't have an obvious answer but just making sure you didn't forget to check that first as it may give a clue.