Tilemap is rendering incorrect tiles somehow

Hi there, I’m seeing some weird behaviour from the Tilemap where seemingly random tiles are turning invisible or sometimes even being swapped out with other tiles, somehow without actually modifying the stored tile data. If I force the tile to re-render by changing some property of a tile that’s used or moving a tile brush over them (without actually painting) then they go back to normal (until they decide to get messed up again!) :exploding_head:

It seems to happen when loading scenes or reloading the domain after a code change (or on build), but I can’t find any reason why. The tiles that get messed up are fairly consistent too, if I fix it once then save, at some point in the future the same tiles will get messed up again… I’ve got a video showing the “fix” here: https://youtu.be/SEjozPTgevA

My tilemaps are inside a prefab, where the tile data is an override on each instance if that’s any help. Beyond that I’m not sure what to look at to try and solve it. Has anyone seen this before?

That does sound pretty sketchy… have you tried just reimporting all in case the asset database is borked somehow??

Are you using source control btw? If you are, then if you leave this stuff messed up and close Unity, is there any file changes to update?

I did upgrade from 2023.2 to 6.0 today (long after seeing the bug first appear) which (correct me if I’m wrong) I think would have triggered a full reimport anyway? Source control would have been a very good idea, unfortunately I’m an idiot and decided I couldn’t be bothered with it when working by myself :smile: Cheers for the suggestions though.

I’m fairly confident it’s related to the prefab situation. I’ve gone and unpacked the prefab with the Tilemaps on in a couple of problem scenes and found those maps are magically back to normal after a build. I can only assume it’s some cached data on the tilemap/renderer that isn’t getting properly detected as a prefab override.

Interesting. This may be due to an API upgrade between the two.

I had this happen on a Prefab.

I made it with an old version of Unity.

The ParticleSystem had (something like) a thing.size field.

I had used and overridden attributes related to a ParticleSystem in the prefab.

In the new version of Unity that field was now renamed to something like thing.scale, and there was a modification to the particular attribute that was deprecated on the new system.

Essentially the thing.scale bits were unable to consistently overlay the base specification, stored in thing.size, until both were consistent.

The solution was to just edit each prefab and wiggle one field on the object in question, save it, save it back, and that will write a file serialized with the latest correct API identifiers. You could probably even write an Editor Script to rip through your project and do it, but I certainly would not try that until I was in source control!!!

If so, this might be helpful to you because I imagine it could be hacked to do prefabs:

Very interesting, thanks! Definitely sounds related, though I think there’s a fair bit of serialized stuff on the tilemap that isn’t exposed in the inspector at all, makes this a bit harder to get to the bottom of. I’ve ended up just unpacking all the instances of the prefab - it was useful early on in the project when I was fiddling around with settings more, but not really necessary anymore.

I’ve got a backup with the issue intact though, if I get time in the future I might just try comparing the serialized text of the prefab & scene instances directly (and not let an editor script mass update things! :smile:)