Search Unity

Reset Tilemap bounds to visible only?

Discussion in '2D' started by TSabos, Mar 25, 2019.

  1. TSabos

    TSabos

    Joined:
    Mar 8, 2015
    Posts:
    94
    I've been messing around with navigation lately and discovered that the bounds of a tilemap get moved out if you accidentally draw a tile and then delete it. This makes sense, but is there a way to recalculate what the bounds of a tilemap "should" be given only visible tiles? This is causing my nav to encapsulate an area about 20x the size it should be due to having the wrong tilemap selected some weeks ago and drawing a tile and then deleting it. This also seems good for performance to be able to recalc the bounds of a tilemap after erasing tiles.
     
  2. RidgeWare

    RidgeWare

    Joined:
    Apr 12, 2018
    Posts:
    67
    Use tilemap.CompressBounds() to reduce the size of the bounds to existing tiles.
     
    adriank5 and TSabos like this.