Resize square sprite to fit unity grid?

Hi, I’m starting to build a 2d game in Unity and my background is basically a bunch of square sprites. It is in my best interest that these square sprites align with the Unity grid (i.e. the grid used to assign position, not a Grid gameobject). However, the 2D square sprite is very slightly off from the size of the Unity grid. Can I resize the sprite so that the height and width is exactly the size of 1 grid square?

Assuming you’re using Rectangle TIlemaps, it should be able simple as going to your texture asset and ensuring that the Pixels Per Unit is the same as the size of the sprite. For example, if your sprite is 64x64 pixels, then a PPU of 64 would make it fit. Then, your Grid should be using a Cell Size of (1, 1) with no CellGap. You might also have to consider the pivot point of the Sprite (is it centered?) relative to the tilemap’s Tile Anchor (is it 0.5, 0.5?) to make sure that each sprite is in the middle of each grid’s cell.

1 Like

I figured it out, the draw mode was tiled and the size was for some reason set to 1.3333. I’m not using Tilemaps.

Well the thing is each of the squares has its own behavior and changes throughout the game, i.e. they are not static/just sitting in the background, and they need to act on their own. Then again I’m a newbie so I don’t know if this can be achieved with tilemaps. I pretty much managed to do what I needed with a SpriteRenderer on each one.

Update: It works, I realized on some of them I had just disabled the BoxColliders in my code.