Hello Guest

Author Topic: Strange tilemap bugs  (Read 15777 times)

fsadeq

  • 2D Toolkit
  • Sr. Member
  • *
  • Posts: 353
    • View Profile
Strange tilemap bugs
« on: July 06, 2012, 10:48:00 pm »
Ok, so here is the deal: Sometimes my prefabs that are hooked up in the tilemap editor will get duplicated after committing the map. I have no idea why it does this, or how to reproduce the error. I just know that it happens sometimes. It will literally duplicate every prefab instance in the map, and once it is committed and I look at the tilemap render data, I see two of every prefab (with the same name, so it will say for example coin 1, coin 1, coin 2, coin 2, coin 3, coin 3, etc. Re-editing and re-committing does seem to fix the issue sometimes, but sometimes I won't even notice there are duplicates until I start noticing slowdown. Any ideas what could be causing this? Thanks!

EDIT: When I look at other tilemaps in other scenes, some of them I am seeing are duplicating up to 5 times! Eik..
« Last Edit: July 06, 2012, 11:26:55 pm by fsadeq »

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Strange tilemap bugs
« Reply #1 on: July 07, 2012, 12:32:14 pm »
This is crazy! The one thing I'm not confident about and think could do this kind of evil stuff is the Undo...

If you can reproduce this in any way, please let me know and I'll sort it out straight away. In the meantime, I'll try to figure out what could cause it.

fsadeq

  • 2D Toolkit
  • Sr. Member
  • *
  • Posts: 353
    • View Profile
Re: Strange tilemap bugs
« Reply #2 on: July 07, 2012, 04:14:26 pm »
I will try hard to reproduce this. It is tricky because there is no visual indication and I could do 100 different things before I notice.

fsadeq

  • 2D Toolkit
  • Sr. Member
  • *
  • Posts: 353
    • View Profile
Re: Strange tilemap bugs
« Reply #3 on: July 07, 2012, 04:48:05 pm »
I figured it out!

If I commit the sprite collection used in the tilemap, it will duplicate all the prefabs! Very strange. I am testing now, each time I press commit on the sprite collection, it will duplicate the prefab instances in the tilemap. I can see it happen in real time, just duplicates and duplicates. It fixes itself once I edit and re-commit the tilemap.

I've also verified that this will affect ALL tilemaps across different scenes that use the same sprite collection. Ack..
« Last Edit: July 07, 2012, 04:50:58 pm by fsadeq »

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Strange tilemap bugs
« Reply #4 on: July 07, 2012, 04:50:27 pm »
Brilliant. I'll get this sorted out for the next release. I'll also post a fix when I have one.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Strange tilemap bugs
« Reply #5 on: July 07, 2012, 06:34:03 pm »
Brilliant. I'll get this sorted out for the next release. I'll also post a fix when I have one.

Sorted. The bug was with ForceBuild - it wasn't clearing existing spawned objects. Its a bit too long to post in here - drop me an email and I'll send it your way.

If you're worried your scenes might have extra spawned objects, simply commit your sprite collections and then load and save the scenes - the changed sprite collection will trigger a forcebuild on all tilemaps.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Strange tilemap bugs
« Reply #6 on: July 07, 2012, 06:39:57 pm »
Note: An invalid sprite collection means the geometry/collider data could have changed and a force build will be triggered and it rebuilds itself at runtime if the saved data isn't up to date.

This is an expensive operation, and should be avoided at all costs - its easy enough to write a simple foreach (scene) load-save-close script and hook that up to all your active scenes, and you could run that as a pre-deploy stage to avoid this altogether.

fsadeq

  • 2D Toolkit
  • Sr. Member
  • *
  • Posts: 353
    • View Profile
Re: Strange tilemap bugs
« Reply #7 on: July 08, 2012, 04:49:56 am »
Thanks for solving this. What do you mean by an invalid sprite collection? In what case would I have one?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Strange tilemap bugs
« Reply #8 on: July 08, 2012, 12:26:42 pm »
Sorry, I meant invalidated sprite collection, not an invalid one. The sprite collection has a buildId, which identifies the build - this is compared to the one in the tileMap. If they don't match, it means something has changed in the sprite collection and the tilemap must be rebuilt.

fsadeq

  • 2D Toolkit
  • Sr. Member
  • *
  • Posts: 353
    • View Profile
Re: Strange tilemap bugs
« Reply #9 on: July 09, 2012, 04:05:43 am »
So is there something I should be careful about, or can I just go about my business now? The update you sent me works well, no longer does the duplicating. Thanks!

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Strange tilemap bugs
« Reply #10 on: July 09, 2012, 08:51:02 am »
Just go about your business as normal - and before you deploy on final target (before a real final build for instance), try to make sure all your scenes with tilemaps are resaved, if the sprite collections have been updated. This will ensure no rebuilding of the mesh will occur at runtime.

You don't HAVE to do it, the system is built to detect and fix this at runtime - most of the time you can just ignore this, unless you're tight on memory, or loading times are getting too long.

TMK

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 16
    • View Profile
    • Dragonhead Games
Re: Strange tilemap bugs
« Reply #11 on: July 09, 2012, 09:37:35 am »
I've noticed this too, that any prefabs referenced in the TileMap gets duplicated when I'm switching from PC/Mac platform to Android (or other platforms) inside Unity, or the other way around.

It's probably caused by the same problem you guys are talking about, but thought I'd mention it just in case it's something else causing it.
« Last Edit: July 09, 2012, 09:39:34 am by TMK »

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Strange tilemap bugs
« Reply #12 on: July 09, 2012, 01:58:46 pm »
Its most likely the same thing. I'll be issuing a new beta soon with this fix in.

fsadeq

  • 2D Toolkit
  • Sr. Member
  • *
  • Posts: 353
    • View Profile
Re: Strange tilemap bugs
« Reply #13 on: July 10, 2012, 04:58:32 am »
Not sure if this is a consequence of the fix, but just now out of nowhere I tried using the "eyedropper" function and the entire "paint" mode is broken. That is, I can only see the layer names, the formatting is all strange, and my entire palette is gone (only in paint mode, I can see the palette in other modes). I get this error along with it:

Code: [Select]
ndexOutOfRangeException: Array index is out of range.
tk2dTileMapEditor.DrawPaintPanel () (at Assets/TK2DROOT/tk2d/Editor/Tilemap/tk2dTileMapEditor.cs:888)
tk2dTileMapEditor.OnInspectorGUI () (at Assets/TK2DROOT/tk2d/Editor/Tilemap/tk2dTileMapEditor.cs:1018)
UnityEditor.InspectorWindow.DrawEditors (Boolean isRepaintEvent, UnityEditor.Editor[] editors, Boolean eyeDropperDirty)
UnityEditor.InspectorWindow.OnGUI ()
System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture)

This also seems to have affected all of my tilemaps that use the same data. Committing/Editing doesn't fix anything (whenever I try, I just get that error above). Strange! I am forever stuck in this broken mode and don't know what to do. All I did was ctrl+click a tile while editing and this immediately happened.  ???

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Strange tilemap bugs
« Reply #14 on: July 10, 2012, 09:22:15 am »
That is weird. The bugfix shouldn't have changed anything related to this - it only did what normally happens when you "Edit" and "Commit".

I'll look into this.