Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice
  2. Ever participated in one our Game Jams? Want pointers on your project? Our Evangelists will be available on Friday to give feedback. Come share your games with us!
    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:
    8,753
    Don't destroy the Tilemap; destroy the GameObject that contains the Tilemap (and the TilemapRenderer).
     
    MartinLukasMikus likes this.
unityunity