Tilemap - Bounds (bug?)

Hi, I’m trying to know the current size of a tile map and for that I’ve experimented with “localBounds” and “cellBounds” but their behaviour is a bit weird.

Here’s a video of what’s happening: Dropbox - File Deleted - Simplify your life

The white border is a gizmo drawing the bounds rectangle (“cellBounds” in this case).

Basically it seems that once the bounds grow they never shrink back even if no tile is present.

Any hints?

[EDIT]
I just noticed there’s a “CompressBounds” method that does what I need - removes the empty bounds space. It’s just a bit weird this has to be done manually, but I guess that will have to do.
In the meantime, if someone knows a better way to do this please let me know!

3 Likes

The bounds of the Tilemap represents the largest previously painted area. CompressBounds will compress the bounds to the extents of actual filled Tiles, and is a rather expensive operation so it is not called automatically. CompressBounds can be called from the menu dropdown of the Tilemap inspector (using the gear dropdown button).

17 Likes