Unity-Technologies / 2d-extras

Fun 2D Stuff that we'd like to share!
Other
1.54k stars 341 forks source link

Tilemap renderer cannot be refreshed after deletion #378

Open Himil88 opened 10 months ago

Himil88 commented 10 months ago

hello.

I wrote a script to delete a tile at a specific location at runtime.

The deletion and tilemap collider refresh worked fine, and I even saw it in the editor.

However, I was having an issue with the renderer not automatically refreshing, leaving the tiles in place.

I tried using Tilemap.RefreshAllTiles(), Tilemap.RefreshTile, and turning the component off and on via script to update the renderer that wasn't cleared, but I couldn't resolve this issue.

The only way was to turn the component off and on directly in the editor.

Unity version: 2023.2.0b16 2D Tilemap Extra version: 4.0.2 Code for delete a tile: Tilemap.SetTile(position, null);

ChuanXin-Unity commented 10 months ago

Sorry about this issue! This sounds like a bug. We will investigate this!

If you could file a bug with the Unity Bug Reporter that would help, thanks!

Himil88 commented 10 months ago

Thank you for answer.

After posting a question and searching for a few more hours, I found the problem and solution.

I think the problem occurred when I adjusted the tilemap outside the camera and then moved the tilemap back into the camera.

Change DetectChunkCullingBounds to Manual, Increasing the range of ChunkCullingBounds solved the problem.

This may be due to my lack of understanding, but the problem may be that the renderer is not automatically refreshed when the tile map is re-rendered on the camera even though DetectChunkCullingBounds is set to Auto.