Hello Guest

Author Topic: Detach Prefab From Tiles at Runtime  (Read 3851 times)

maaton

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 4
    • View Profile
Detach Prefab From Tiles at Runtime
« on: November 11, 2014, 10:56:46 pm »
Hi.

first of all I must say, 2dtoolkit tile map is simply awsome and it is a delight to use it. One question:

Every time I update the map and use SetTile() all tiles that have prefabs attached to them are instantiated again and Start() is called again on their script.
Is there a way to somehow "detach" all prefabs at runtime after I don't need them anymore? I use SetTile() quite often and I just couldn't figure this one out.

Thank you for your help in advance!

Marton

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Detach Prefab From Tiles at Runtime
« Reply #1 on: November 12, 2014, 10:17:19 am »
Easiest way is to keep all the prefab related stuff in one layer, tk2d only rebuilds changed layers. Alternatively I can get you a patch that will not spawn prefabs at runtime, there's no way to reliably keep track of prefabs at runtime so tk2d just doesn't do it.

maaton

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Detach Prefab From Tiles at Runtime
« Reply #2 on: November 12, 2014, 07:36:15 pm »
I need to update both layers at the same time so I think I'll just put extra copies of the associated tiles to the tilesheet, one with prefab, one without.

Anyway,

thanks for your promt reply and great support!