So I'm trying to optimize my dungeon generation. Currently I use a similar method to the "3D Castle Maze" example. I generate a tilemap at runtime that then creates 3D objects as solid walls on each applicable tile.
However ideally I would like to optimize this further. Because my generated dungeons can be quite large and complex, and because I am spawning hundreds of enemies, I do start to see performance drops when I reach 900+ objects.
One way to reduce the number of 3D objects is to identify straight lines of repeating tiles and create a single 3D object that is the length/width of those identical tiles (plus their corners) instead of one 3D object per tile.
I have an over complicated, very broken version of this already so I'm hoping someone can point me to a simpler solution to this. Currently I ID every "corner" tile and repeat a check in 1 direction for that corner until it ID's a different corner, and spawn the 3D object based on that information. Unfortunately this is really complicated and falls apart a bit at some weirder junctions you can see in the screenshot below: