Unity-Technologies / 2d-extras

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

Is it safe to use 'Really tiny Grid' for tilemap? #255

Open WhiteDog123 opened 3 years ago

WhiteDog123 commented 3 years ago

Hi y'all.

I already questioned this to unity community. but I want to hear this from actual contributor of tilemap. I don't know how to contact with them so I posted in here. If this post is not appropriate, It's okay to move or remove.

We were currently using tilemap, but there was a little problem that it seems not natural when placing little things like flowers, etc. like you can seeing from pictures below.

image image

So what I did was, make the grid size smaller than usual. Previously, the size was (1, 1) for representing 16 x 16, But I made to (0.0625, 0.0625) for representing 1 x 1 pixels.

and there was no different for size of files. even when I open the scene with code editor, there's no difference. only difference was occur when I place actual tiles. it wasn't depend on grid size.

even in this article(https://www.reddit.com/r/Unity2D/comments/8gmn55/limiting_the_size_of_my_tilemap_grid/) says "Tilemaps actually store the individual TileBase references for each cell sparsely." So I think there will be no problem even I use tiny tiny grid.

In conclusion, it is working but I'm not sure it is the appropriate way for using tilemap. I am worrying about there might be some performance issue.

So, could you guys tell me there could be any potential problem for this? Or introduce me any article that can tell me about the performance of grid, tilemap, etc? Or better way to achieve my goal?

I already have read this article(https://unity.com/how-to/optimize-performance-2d-games-unity-tilemap) but it was about comparing tilemap and non-tilemap scene. So this was not what i want.

ChuanXin-Unity commented 3 years ago

Hi, for your particular case, you could try using the Select Tool (first tool in the toolbar) and select the Flower Tile in your Tilemap. In the inspector, you can adjust the exact position of the Flower Tile through the field or with the Position tool there. You will be able to pick and paint your Flower Tile at the same position in the cell after that.

Regarding the performance of this, the TilemapRenderer handles Tiles better when they are closer together as they are grouped based on their positions in chunks, eg. 16x16 groups of Tiles. If you are going for a 1x1 pixel Grid size, you could try increasing your TilemapRenderer.chunkSize to ensure that your Tiles are grouped better.

Let us know if that helps!