Search Unity

Question Selection in 'Scene' is bigger than Tilemap object

Discussion in '2D' started by Blazeryz, Jan 1, 2023.

  1. Blazeryz

    Blazeryz

    Joined:
    Jun 20, 2020
    Posts:
    4
    Hi,

    I'm working on a code snippet that creates chunks of tilemaps (so I can later deactivate the ones the character / camera doesn't see). It's technically working as expected but when I select one of these tilemaps in my scene window while the game is running the selection is much larger than the actual tilemap and I can't figure out why.

    Here's a picture of the generated map with one of the chunks selected and in its original position and then when i drag it to the side so it's hopefully clearer when i say the selection is larger

    Any advice would be much appreciated.

    upload_2022-12-31_19-30-33.png

    upload_2022-12-31_19-30-44.png
     
  2. ChuanXin

    ChuanXin

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    1,068
    Hi, I assume that the selection is a single Tilemap? The size of the selection should be based on the Origin and Size of the Tilemap. After creating a chunk, you could check if the Origin and Size of the Tilemap fits the chunk, and if not, you could use Tilemap.CompressBounds to fit the bounds for your chunk.