How do I set the scale of a tile?

How do I change the scale of my tile (Like you do when you change the scale of a Transform component)?


I cant find anything like this on my tile objects.

Scaling is done with a Matrix4x4. You can set it with TileMap.SetTransformMatrix or TileData.transform.

1 Like

@Jay-Pavlina Where would I do this exactly, is there no way to do it in the inspector (Like scaling up a gameobject)?

1 Like

Are you trying to scale just one tile on the tilemap or your tile set to be scaled?

I’m trying to scale every tile so that they fit into a 64 by 64 grid even though the graphics are 16 by 16 pixels (I still want the pixels per units at 1)

Not sure if this is an ideal solution.
Select the tile asset and set the transform values.
Set Flags to Lock Transform

Currently the Tilemap Palette will not adjust to the size, so to select the tile click in the middle of the image.
I’m curious as to why you’re using these values. Could you share a little on what you’re doing and why?

Can you give more insight why you insist on pixelPerUnit=1 and fitting 16x16pixel assets into 64x64 world unit grid?

@keely @Johaness_Reuben First I set the cameras size to be the screen height / 2. I also offset the camera position by 0.1 in the x and 0.1 in the y. This removes all pixel streatching (Imgur: The magic of the Internet). Then I set my pixels per unit on all my assets to 1 and then scale them to the approprite size using the transform options. This makes every unity unit one pixel on my screen. This gives me pixel pericise control of the positioning of my sprites (As long as I move using transform.Translate() or transform.position += …). I also round the position of moving objects (also to remove pixel streatching). I created my own collision system using raycasts and kinematic ridgidbodys so I dont have to use the physics system. This setup is great for pixel art games since I can for example fine tune the speed of objects to remove jerkyness/choppyness and I overall have alot more control.

@Johaness_Reuben Yeah, I agree its not and ideal solution (It works though I guess). If you belive its a good enough feature maybe you guys can create a easyer to use and better solutiuon to this. Something like "the normal transform scaling tools" and fix so that the pallet dosent totally mess up. Anyway thanks for all the help. :smile:

I’m assuming you want x4 pixelart (one texel is four screen pixels).

pixelsPerUnit=0.25 produces exactly the same rendering outcome than using 4x scaling matrix.

Some differences in scripting:

  • Transform local space calculations differ (easy to match, though)
  • Transform scale affects children whereas pixelsPerUnit doesn’t
  • Perhaps something else I’m missing?

In any case, sounds like you are fond of your approach and don’t want to change already working systems. Scaling per Tile asset like suggested is unfortunately your only option if you want to have grid size differ from your asset size.

@keely @Johaness_Reuben I've got no problem scaling every tile asset. It seems to work pretty well, only problem is the pallet. If you can fix that, this would be a good solution. One thing I dont really understand is the flags on the tiles (Override Transform, override color, none etc). Can anyone explain?

One solution is to make a tilemap, set the size of the tiles to automatic, then the first tile you drag and drop into the editor will determine the size of the tiles.

I also have the same problem. When I drag in my 16px 16px image, it don't fix the box.

6156543--672873--Screen Shot 2020-07-31 at 4.36.50 PM.png

exact same problem, can enyone help out?

  1. Go to Tile Palette
  2. Select Cursor icon (shortcut = S)
  3. Ensure Tile Palette’s target Tilemap is correct
  4. Select Tilemap with mouse in scene.
  5. Look at Inspector’s Grid Selection info. If there’s nothing there, you have the wrong target tilemap in Tile Palette.
  6. Change scale.

6514959--734484--Untitled - Copy.png

You can also change it by script using tilemap.SetTransformMatrix(cell, newMatrix).

HOWEVER, that said this problem:

Actually looks like the image has the wrong pixels per unit (PPU). To fix that, go to the sprite’s texture and adjust its PPU.

I changed the PPU of my tile and it had no effect. Also, changing the scale of the tilemap does just that: changes the scale of the tile map, not of the tiles relative to the tilemap. So, no solution still? I’d think this would be like, super-basic.

This shouldn’t be the case. Did you try much larger/smaller values? Just in case I’m not clear, I’m talking about Pixels Per Unit on the sprite’s texture.

You might also try by script: tilemap.SetTransformMatrix(cell, newMatrix) or you could create a custom tile that sets the tileData.transform automatically. It could expose a scale property for convenience.

Change the cell size of the Grid. It will fix the problem. QED. 8-)