Hello Guest

Author Topic: TileMap: weirdness when using it as a Prefab  (Read 6340 times)

ccampama

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 35
    • View Profile
TileMap: weirdness when using it as a Prefab
« on: October 14, 2013, 08:41:46 pm »
Hi,

I have a TileMap already designed. Then I want to replicate it for 10 scenes and would like that any modification in it on any given scene would be automatically generated in any other scene. So I created a prefab of this TileMap. Then, when I open other scenes, I try to drag the prefab from the Project window to the Hierarchy, but to my surprise:
- Whenever I cross any of the views in Unity while dragging the prefab, I can see that in the hierarchy is appearing a TileMap Render Data. So if I move the mouse around the screen on and on while dragging, I get tons of Render Data objects.
- I also end up getting this exception while in the editor:
"
KeyNotFoundException: The given key was not present in the dictionary.
System.Collections.Generic.Dictionary`2[tk2dRuntime.TileMap.Layer,System.Boolean].get_Item (tk2dRuntime.TileMap.Layer key) (at /Applications/buildAgent/work/c514da0c8183631c/mcs/class/corlib/System.Collections.Generic/Dictionary.cs:150)
tk2dRuntime.TileMap.BuilderUtil.CreateRenderData (.tk2dTileMap tileMap, Boolean editMode, System.Collections.Generic.Dictionary`2 layersActive) (at Assets/TK2DROOT/tk2dTileMap/Code/tk2dTileMapBuilderUtil.cs:317)
tk2dTileMap.Build (BuildFlags buildFlags) (at Assets/TK2DROOT/tk2dTileMap/Code/tk2dTileMap.cs:276)
tk2dTileMap.EndEditMode () (at Assets/TK2DROOT/tk2dTileMap/Code/tk2dTileMap.cs:486)
tk2dTileMap.Awake () (at Assets/TK2DROOT/tk2dTileMap/Code/tk2dTileMap.cs:121)
"
 Couldn't tell exactly when.
- If I delete all the Render Data instances and leave only the one that seems to be working, if I make a modification to the TileMap (adding some random tiles), it seems to ignore it in runtime (but I can see the new tiles in the editor!). And if I switch to another scene (commiting the TileMap and Applying the changes to the Prefab just before), the changes to the TileMap are ignored even in the editor.

 Is all this erratic behaviour because I am doing something wrong trying to create a Prefab of aTileMap? Should I do it in another way?

 I see that other option is to Additively load a scene that has this TileMap. Is it a much better solution?

 Thank you very much in advance!


« Last Edit: October 14, 2013, 09:35:09 pm by ccampama »

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: TileMap: weirdness when using it as a Prefab
« Reply #1 on: October 14, 2013, 10:01:07 pm »
Are you on 2D Toolkit 2.2.2?

ccampama

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 35
    • View Profile
Re: TileMap: weirdness when using it as a Prefab
« Reply #2 on: October 14, 2013, 10:21:18 pm »
Yes, updated it this morning. v2.2.2.
I've just right now implemented it using LoadLevelAdditive and it's working fine. Also, as expected, the scene file' sizes are much smaller now.
But let me know if you need any further information on trying to reproduce the weird behaviour that I explained above.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: TileMap: weirdness when using it as a Prefab
« Reply #3 on: October 15, 2013, 10:46:16 am »
Hey there - found this issue. Unfortunately it snuck in when fixing something else. Drop me an email and I'll sort you out with a patch to fix this.

ccampama

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 35
    • View Profile
Re: TileMap: weirdness when using it as a Prefab
« Reply #4 on: October 15, 2013, 01:00:17 pm »
I've send you an email with the address. Thank you very much!

subliminalman

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: TileMap: weirdness when using it as a Prefab
« Reply #5 on: October 20, 2013, 02:34:40 am »
Was this fixed? I am getting this KeyNotFoundException as well.

When I instantiate the prefab with the tilemap via code it draws the prefabs in the tilemap correctly but not the sprites that do not have a prefab connected to them. I am on version 2.2.3 and I am instantiating via Resources.Load


Thanks

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: TileMap: weirdness when using it as a Prefab
« Reply #6 on: October 20, 2013, 11:46:02 am »
Yes it should be fixed in 2.2.3. Perhaps iyou're experiencing a different issue? Can you create a repro case and send to support at unikronsoftware.com?