Scale and rotate pixel art precisely in URP
Configure a pixel perfect camera
Add a pixel perfect camera
The pixelThe smallest unit in a computer image. Pixel size depends on your screen resolution. Pixel lighting is calculated at every screen pixel. More info
See in Glossary perfect cameraA component which creates an image of a particular viewpoint in your scene. The output is either drawn to the screen or captured as a texture. More info
See in Glossary in the Universal Render PipelineA series of operations that take the contents of a Scene, and displays them on a screen. Unity lets you choose from pre-built render pipelines, or write your own. More info
See in Glossary (URP) automatically adjusts the camera resolution so that spritesA 2D graphic objects. If you are used to working in 3D, Sprites are essentially just standard textures but there are special techniques for combining and managing sprite textures for efficiency and convenience during development. More info
See in Glossary 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:
- Set up your sprites for the pixel perfect camera.
- Add a Pixel Perfect Camera component to your main camera.
- Set snap settings so sprites move in pixel-perfect increments.
Set up your sprites
Follow these steps:
- Select all your sprites in the Project window, and set their Pixels Per Unit properties to the same value.
- In the Advanced section of the InspectorA Unity window that displays information about the currently selected GameObject, asset or project settings, allowing you to inspect and edit the values. More info
See in Glossary window, set Filter Mode to Point.
- Set CompressionA method of storing data that reduces the amount of storage space it requires. See Texture Compression, Animation Compression, Audio Compression, Build Compression.
See in Glossary to None.
- Select Open Sprite Editor.
- 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:
- Select the main camera in the Hierarchy window.
- In the Inspector window, select Add Component.
- Type
pixel, then select Pixel Perfect Camera.
- Set Assets Pixels Per Unit to the same value as the Pixels Per Unit property of your sprites.
- 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 SceneA Scene contains the environments and menus of your game. Think of each unique Scene file as a unique level. In each Scene, you place your environments, obstacles, and decorations, essentially designing and building your game in pieces. More info
See in Glossary 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:
- In the Scene view, open the Grid and Snap overlay ().
- In the Grid and Snap overlay, select the dropdown.
- 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).
- 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