Search Unity

  1. Get the latest news, tutorials and offers directly to your inbox with our newsletters. Sign up now.
    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:
    5
    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:
    9,442
    Don't destroy the Tilemap; destroy the GameObject that contains the Tilemap (and the TilemapRenderer).
     
    MartinLukasMikus likes this.
unityunity