Gathering information about different bugs related to Tilemaps in Unity 6.4, 6.5, and 6.6 in one post just in case anyone runs into them. One might be a Sprite Atlas bug instead though. If you have any tilemap related posts please drop it here. Just trying to put stuff together to help a set of bug reports I am sending to Unity.
Videos at the bottom showcases the crashes and different issues to help visualize if somethign is happening to other people.
Hard Crashes:
Two possibly different crashes related to the Tilemap have been noticed.
Link to bug report for one with a fix already in review and coming to some Unity versions next week and more the week after. The other one I am writing a bug report on, but it might also be fixed by the first bug fix in progress already.
If anyone is getting a crash for tilemaps when painting a tile and the crash is around something that goes into any of the following: RuleMatches for rule tiles, any tile RefreshTile method, or GetTileData check the following to see if the crashes stopped.
-
You have any scripts that listen to the
Tilemap.tilemapTileChangedcallback for when tiles changed happening in editor or playmode. Try unregistering event listeners to theTilemap.tilemapTileChangedcallback and see if that helps. -
If you got domain and scene reload turned off. - Try turning it on and clearing static reference to any tilemap or tilemap callback than turning it back off and seeing if that helps. - There was a bug in 6.4 and 6.5, but it was fixed in Unity 6.4 beta 8, but an edge case might of been missed.
Can’t tell for sure, but this might be related to a dictionary or haset in rules tiles not being cleaned up correctly when domaon/scene reload is off. Not sure though what the exact thing was.
Bug report case id was IN-123724 for anyone wondering about this one.
Link to confirmaion by staff it was fixed. Haven’t ran into this one personally after the fix in 6.4 beta 8, but something similar could be happening still.
-
Check if the crash is happening around
UnityEditor.Tilemaps.PaintableSceneViewGrid:OnSceneGUIvia the editor crash log. Be near the very bottom after a crash. This one is the one I am trying to figure out how to make a good bug report on. Will update post when a work around is found. -
If your tiles are from an Aseprite file and you have background import for Aseprite files turned on and your crash log says something related to PreviewImporter that ends up calling
UnityEditor.Tilemaps.PaintableSceneViewGrid:OnSceneGUI
Example to show what the crash log could look like when running into the 3rd or 4th mentioned crash scenario.
core::flat_set<math::int3_storage,TilemapPosition_Less,core::allocator<math::int3_storage,0> >::insert
Tilemap::RefreshTileAsset
Tilemap_CUSTOM_RefreshTile
(wrapper managed-to-native) UnityEngine.Tilemaps.Tilemap:RefreshTile_Injected (intptr,UnityEngine.Vector3Int&)
UnityEngine.Tilemaps.Tilemap:RefreshTile (UnityEngine.Vector3Int)
UnityEngine.Tilemaps.ITilemap:RefreshTile (UnityEngine.Vector3Int)
UnityEngine.Tilemaps.TileBase:RefreshTile (UnityEngine.Vector3Int,UnityEngine.Tilemaps.ITilemap)
(wrapper runtime-invoke) <Module>:runtime_invoke_void__this___Vector3Int_object (object,intptr,intptr,intptr)
[C:\build\output\Unity-Technologies\mono\mono\mini\mini-runtime.c:3445] mono_jit_runtime_invoke
[C:\build\output\Unity-Technologies\mono\mono\metadata\object.c:3068] do_runtime_invoke
[C:\build\output\Unity-Technologies\mono\mono\metadata\object.c:3115] mono_runtime_invoke scripting_method_invoke
ScriptingInvocation::Invoke
InvokeRefreshTile
Tilemap::RefreshTileAssetsInQueueFromArrays
Tilemap::RefreshTileAssetsInQueue
Tilemap::RefreshAndSyncTileAssetsInQueue<1>
Tilemap::SetEditorPreviewTileAsset
Tilemap_CUSTOM_SetEditorPreviewTileAsset (wrapper managed-to-native) UnityEngine.Tilemaps.Tilemap:SetEditorPreviewTileAsset_Injected (intptr,UnityEngine.Vector3Int&,intptr)
UnityEngine.Tilemaps.Tilemap:SetEditorPreviewTileAsset (UnityEngine.Vector3Int,UnityEngine.Object)
UnityEngine.Tilemaps.Tilemap:SetEditorPreviewTile (UnityEngine.Vector3Int,UnityEngine.Tilemaps.TileBase)
[.\Library\PackageCache\com.unity.2d.tilemap@93aebd748a84\Editor\GridBrushEditor.cs:906] UnityEditor.Tilemaps.GridBrushEditor:SetTilemapPreviewCell (UnityEngine.Tilemaps.Tilemap,UnityEngine.Vector3Int,UnityEngine.Tilemaps.TileBase,UnityEngine.Matrix4x4,UnityEngine.Color)
[.\Library\PackageCache\com.unity.2d.tilemap@93aebd748a84\Editor\GridBrushEditor.cs:593] UnityEditor.Tilemaps.GridBrushEditor:PaintPreview (UnityEngine.GridLayout,UnityEngine.GameObject,UnityEngine.Vector3Int)
[.\Library\PackageCache\com.unity.2d.tilemap@93aebd748a84\Editor\GridBrushEditor.cs:232] UnityEditor.Tilemaps.GridBrushEditor:OnPaintSceneGUI (UnityEngine.GridLayout,UnityEngine.GameObject,UnityEngine.BoundsInt,UnityEngine.GridBrushBase/Tool,bool)
[.\Library\PackageCache\com.unity.2d.tilemap@93aebd748a84\Editor\PaintableSceneViewGrid.cs:372] UnityEditor.Tilemaps.PaintableSceneViewGrid:CallOnPaintSceneGUI ()
[.\Library\PackageCache\com.unity.2d.tilemap@93aebd748a84\Editor\PaintableSceneViewGrid.cs:91] UnityEditor.Tilemaps.PaintableSceneViewGrid:OnSceneGUI (UnityEditor.SceneView)
Other posts related to build failing or crashing in editor.
Tilemap not rendering correctly:
If your tiles are not rendering properly in Unity 6.5 or newer check sprite atlas settings. After updating to Unity 6.5 for some reason Sprite Atlas in editor started malforming my tile sprites. I need to see what all changed for Sprite Atlas in 6.4 and 6.5.
There honestly is more to the issue outside of Sprite Atlas, but wanted to share a possible thing to check. One of the videos at the bottom shows off the sprite corruption issue. This happens when dragging the sprite into scene and when making the sprite a tile it gets worse.
Another issue was tiles were being painted, but the sprites were coming up null on the grid position where the tile was painted at. Check the last video at the bottom of the post for examples on that and how to see if this is a problem you could be running into.
Link to another thread tilemaps not rendering.
Videos
Jet brains opens randomly in the first video because I have certain exceptions that auto open it and tries to log it. This video crash is caused by Tilemap.onTilemapTilesChanged. I was making a custom PhysicsShape for Tilemap using the PhysicsCore2D API and listened to the callback when tiles changed to update the Tilemap PhysicsShape and PhyiscsBody. The tile changed queue in Unity’s RefreshTileAssetsInQueueFromArrays method was causing a native crash for an index of a tile that was out of the range of the array for tiles needing synced.
This video showcases a possible reason some Tilemap sprites don’t render correctly. Turning off Sprite atlas v2 in editor for Unity 6.5 fixed this issue for me at least. Sometimes the tile just didn’t render anything at all.
This video shows a bug that was fixed already in Unity 6.4 beta 8, but showcasing it for anyone who is still running into it. Tiles were trying to set their sprites to null. This is a hard crash example.
Sorry @ChuanXin to ping you, but you are the only staff member in forums I have seen invoved in this area of work that works on the Tilemap stuff. Hope this helps a little bit.
I have two different bug reports and small projects coming to Unity via the bug reporter. Will edit this post with their case ids to make life easier for anyone reading this when I get the bug report confirmation numbers.