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
  2. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  3. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Is there any way to "refresh" the tile map size?

Discussion in '2D Experimental Preview' started by muffin1, Oct 2, 2016.

  1. muffin1

    muffin1

    Joined:
    Sep 25, 2016
    Posts:
    8
    Hi all,

    I'm wondering if there is any way to refresh the tile map size.

    If I create a tile map and start drawing, the tile map size will increase, but if I delete some of the tiles at the edges the actual returned value (tileMap.size.x and tileMap.size.y) return the original value.

    Is there any way I can manually (or automatically) refresh/recalculate this boundary so I can have the correct value returned?

    I am clamping the camera position to the size of the tile map, and this is where the issue was found. I've tried calling "RefreshAllTiles()" and also tried getting the values from "tileMap.size" and "tileMap.editorPreviewSize" with no luck.

    I've noticed that in the scene view that if you select the "rectangle" tool (the 5th icon, right of the hand/grab tool) and then select the tile map layer it will show you the current bounds. Some times if I just keep within the original boundary it will work, but sometimes just drawing a box will make the boundary bigger than the actual map.

    Thanks,

    Tom

    Edit:

    I've found a different way to access the values I needed so this isn't much of an issue anymore.

    I'm now getting the values from the TileMapCollider2D component using it's bounds center point and size.

    Still would be good to know of a way of fixing the original problem but this method works fine.
     

    Attached Files:

    Last edited: Oct 2, 2016
  2. Frizle

    Frizle

    Joined:
    Sep 12, 2017
    Posts:
    1