Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Tilemap - Bounds (bug?)

Discussion in '2017.2 Beta' started by luispedrofonseca, Oct 11, 2017.

  1. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    943
    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: https://www.dropbox.com/s/gyquw76k4j6hwqy/tilemap_bug.mp4?dl=0

    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!
     
    Last edited: Oct 11, 2017
    Frizle, jehk27 and info_unity581 like this.
  2. ChuanXin

    ChuanXin

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    1,068
    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).