How do I change the size of a tilemap? I’m probably missing something really obvious here, but I can’t seem to change the size of my tilemap. Currently, it’s stuck 5x6 but I want to be 20x20. Is there any way to change this?
Hello @IamDumb,
I was trying to manually set the size of a tilemap today and the values I was getting from the script API just weren’t making sense to me.
tilemap.cellBounds, tilemap.size, tilemap.localBounds were all showing me dimensions that didn’t match what I was seeing in my scene.
What I found was that enabling “Debug Mode” allowed me to view and change the size of the tilemap in the inspector. Debug mode can be enabled by clicking the dropdown button next to the lock icon at the top right of the inspector window.
One thing I noticed after doing this was that painting tiles in the scene will automatically change the size of the tilemap if you go outside of the defined bounds of the tilemap. So if you have your 20x20 size tilemap and you paint in a tile one space to the right of the right bounds the tilemap will resize to 21x20.
Hello @IamDumb !
There are a few different ways of resizing the tilemap, each comes with a different result:
-
Change the Scale or Cell Size of Grid – when you create a new Tilemap, Unity will automatically generate two game objects: a Grid with a Tilemap child. You can change the Scale field of the Grid’s transform or Cell Size in the Grid component. Changing the scale will stretch all tiles in the tilemap, whereas changing the Cell Size will leave the tiles unchanged – only the actual size of a cell will be changed.
-
Scale the game object with Tilemap component attached – this will stretch all tiles in all scaled directions,
-
Change orientation to Custom – by changing the Orientation field of Tilemap component, the Scale fields are now editable. Changing this field will resize the sprite of each tile, leaving the actual cell size untouched (this might cause tiles to overlap),
-
Change the size of the particular tiles – by clicking on a tile in a Tile Palette window will show Grid Selection in the Inspector. You can change the Scale field of a tile, which have a similar effect as step 3, but will affect only a particular tile.
We hope one of the solutions we suggested will solve your problem!
All the best,
The Knights of Unity