Search Unity

Tilemap - Removing a bunch of tiles in runtime is extremely slow

Discussion in '2D' started by Wulfara, May 26, 2018.

  1. Wulfara

    Wulfara

    Joined:
    Aug 11, 2015
    Posts:
    40
    Hello. I'm trying to create a destroyable environment using the 2D tilemap feature. I have a very simple sceneario with a small grid of 4x4 white tiles with grid colliders.

    Creating new tiles in runtime with Tilemap.SetTile(Vector3Int, Tile) is very fast, I can create tons of them per frame as shown in the image. But when it comes to removing tiles -using Tilemap.SetTile(Vector3Int, null)- it perfoms really bad. I can remove a tile or two in a frame whithout noticing a fps impact but if I try to remove an higher number of tiles the game freezes for a while in that frame.

    Is there a more performant way of doing this?

    I'm running Unity 2018.1 with Intel i5 3.2GHz, 14GiB RAM, and Nvidia 950 GTX.

    Thank you and excuse me for my bad English.

    tilemap.png