Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Tilemap CompressBounds() doesn't update

Discussion in '2D' started by Locrian, Jul 13, 2020.

  1. Locrian

    Locrian

    Joined:
    Jun 30, 2020
    Posts:
    5
    I'm not sure how I'm supposed to make good use of the CompressBounds() function when it doesn't update until I manually make a change to the tilemap. What's up with this? I call CompressBounds(), but it won't do anything to the bounds until I make any change at all to it, e.g. having the tile palette window out and putting my mouse over the tilemap (which changes the bounds itself). Is there a way to refresh everything without putting my mouse over it?
     
  2. raarc

    raarc

    Joined:
    Jun 15, 2020
    Posts:
    535
    the function is useful during runtime it updates correctly
     
  3. Locrian

    Locrian

    Joined:
    Jun 30, 2020
    Posts:
    5
    I might be encountering a bug or something then, I'm not sure what I'm doing wrong. Doing CompressBounds() only does so on time the first time I call it. The next times I call it, the bounds don't update until I move my mouse onto the scene again. Sometimes it doesn't properly bounds at all, not even the first time. I'm using Unity 2019.4.2f1 (LTS).
     
  4. raarc

    raarc

    Joined:
    Jun 15, 2020
    Posts:
    535
    try using debug.log to check your bounds size before and after you call compress

    you shouldnt need to navigate the scene view to check it
     
  5. Locrian

    Locrian

    Joined:
    Jun 30, 2020
    Posts:
    5
    Alright so here was the misunderstanding. It turns out Tilemap and Tilemap Renderer have two different bounds. I was trying to use the Tilemap Renderer's bounds thinking it would be the exact same. When you create a Box Collider, it defaults to matching the size of the Tilemap Renderer bounds rather than the bounds of the Tilemap itself.