Hello Guest

Author Topic: Safe to Instantiate a TileMap?  (Read 3780 times)

ilikepopsoda

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 4
    • View Profile
Safe to Instantiate a TileMap?
« on: April 24, 2013, 03:08:25 am »
So I've been playing around with TileMap prefabs the past couple nights with some confusing results.

When I make a prefab with a TileMap, delete the original object that I used to create the prefab, and then drag the newly created prefab reference into the scene to create an instance, the tilemap does not display anything there. The tiles will pop back into existence if I hit the "edit" button in the inspector, which is weird.

Now if I create a prefab from the same TileMap before I hit commit, in other words when I'm actually in Edit Mode, everything seems to be okay. When instanced while the game is running, the TileMap that I thought would be uncommitted, seems to have "committed itself" and it's ready for use.

I guess my main concern is: Am I going to run into problems down the road with this method of creating a prefab from an "uncommitted" TileMap object?

I hope that all makes sense. :\

Thanks,
Gerald

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Safe to Instantiate a TileMap?
« Reply #1 on: April 24, 2013, 11:24:35 am »
Yes it does make sense.

This isn't officially supported for various reasons, the main one being how long it takes to build a tilemap. It is often easier to have each tilemap in its own scene, and then use LoadSceneAdditive to load the one you want in.

If you instantiate a tilemap, you should probably call ForceBuild() immediately to make sure the geometry, etc. are generated.

ilikepopsoda

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Safe to Instantiate a TileMap?
« Reply #2 on: April 24, 2013, 11:03:07 pm »
Thanks! I'll check that out.