Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

How to destroy Tilemap via script

Discussion in 'World Building' started by MartinLukasMikus, Aug 8, 2019.

  1. MartinLukasMikus

    MartinLukasMikus

    Joined:
    Jul 12, 2019
    Posts:
    3
    Hello, I'm creating simple 2d platformer, and generating the world "infinitely". So I started with chunks everything went well until I found out that I don't know how to destroy them. Every chunk is a Tilemap which is being stored in Dictionary w/ it's Vector2 in world position. If I try to use Destroy(foregroundMap[new Vector2(x,y)]); in unity I'm getting an error :
    "Can't remove Tilemap because TilemapRenderer depends on it"
    Any suggestions please ?
     
  2. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    8,056
    Don't destroy the Tilemap; destroy the GameObject that contains the Tilemap (and the TilemapRenderer).
     
    MartinLukasMikus likes this.