0
votes

My scene has a Grid that contains several Tilemaps. For some reason, Unity has given some of my tilemaps bounds that are larger than the area that's covered by tiles, as shown in the screenshot below. If I try to erase the unused area that's inside of the tilemap's bounds (shown by that gray rectangle in the screenshot), Unity does not shrink the tilemap and it will actually expand the tilemap to include any other tiles that I moved the eraser over.

enter image description here

How do I get Unity to shrink my tilemap's bounds to include only the cells that have a tile in them?

1

1 Answers

2
votes

You can use Tilemap.CompressBounds() to recalculate the origin and bounds of your tilemap.
If you want this to be recalculated in the editor you can create a script that calls Tilemap.CompressBounds() with the [ExecuteInEditMode] tag at the top.