Version: Unity 6.0 (6000.0)
Language : English
Scale and rotate pixel art precisely in URP
Configure a pixel perfect camera

Add a pixel perfect camera

The pixel perfect camera in the Universal Render Pipeline (URP) automatically adjusts the camera resolution so that sprites render with perfect pixels at different screen resolutions. This prevents pixel art looking blurry, or distorting when sprites move or rotate.

Important: The pixel perfect camera is included by default when you set up a project for 2D games with the Universal 2D template. Don’t install the separate 2D Pixel Perfect package, which works only with the Built-In Render Pipeline.

Follow these steps:

  1. Set up your sprites for the pixel perfect camera.
  2. Add a Pixel Perfect Camera component to your main camera.
  3. Set snap settings so sprites move in pixel-perfect increments.

Set up your sprites

Follow these steps:

  1. Select all your sprites in the Project window, and set their Pixels Per Unit properties to the same value.
  2. In the Advanced section of the Inspector window, set Filter Mode to Point.
  3. Set Compression to None.
  4. Select Open Sprite Editor.
  5. For each sprite in the texture, in the Sprite overlay, set Pivot to Custom and Pivot Unit Mode to Pixels. The pivot point now snaps to pixels.

Add the Pixel Perfect Camera component

Follow these steps:

  1. Select the main camera in the Hierarchy window.
  2. In the Inspector window, select Add Component.
  3. Type pixel, then select Pixel Perfect Camera.
  4. Set Assets Pixels Per Unit to the same value as the Pixels Per Unit property of your sprites.
  5. Set Reference Resolution to the pixel art resolution of your game. For example, if you set X to 320 and Y to 180, Unity sets the camera view to 320 sprite pixels in width and 180 sprite pixels in height.

In the Scene view, Unity displays the following:

  • A dotted green outline of the area set in the Reference Resolution property.
  • A solid green outline of the area visible in the Game view.

Note: If you use the Cinemachine package, for more information about making Cinemachine compatible with the pixel perfect camera, refer to Make Cinemachine compatible with the pixel perfect camera.

Set snap settings

Follow these steps:

  1. In the Scene view, open the Grid and Snap overlay ().
  2. In the Grid and Snap overlay, select the dropdown.
  3. Set Grid Size to 1 divided by the Asset Pixels Per Unit value of the Pixel Perfect Camera component. For example, if the Asset Pixels Per Unit is 100, set the X, Y, and Z values of the Grid Size property to 0.01 (1 divided by 100).
  4. Enable Grid Snapping ().

To snap sprites to smaller increments of the grid, press Ctrl + [ (macOS: Cmd + [) to decrease the grid size, or Ctrl + ] (macOS: Cmd + ]) to increase the grid size.

Additional resources

Scale and rotate pixel art precisely in URP
Configure a pixel perfect camera