Finding The Right Pixels Per Unit Value For Your 2D Mobile Game
Determining Optimal Pixels per Unit
The pixels per unit value is a key setting in Unity that determines how many pixels in the game correspond to one unit of measure in the game world. This scaling factor impacts the visual quality and performance of 2D games, so finding the right balance is essential.
Why Pixels per Unit Matters for Visual Quality
The pixels per unit value directly controls the size at which sprites and other game elements are rendered. A high value results in small, hard-to-see assets while a low value enlarges those elements and reduces image quality through pixelation and blurring.
For example, a character sprite exported at 32×32 pixels can appear sharp and clear or chunky and blurred depending on the pixels per unit configured in the project. Setting an appropriate value ensures assets are rendered at intended sizes without loss of quality.
Calculating Canvases and Screen Sizes
The first step in optimizing pixels per unit is to analyze target screen resolutions and calculate dimensions for the game canvas and UI canvases.
For a mobile game, examine the most common resolutions and aspect ratios for modern phones and tablets. Measure out the usable screen space in Unity units based on a 16:9 aspect ratio rather than simply using 1080p or 720p resolutions, which may not match devices in landscape orientation.
These calculations establish a maximum width and height for each canvas. Next, think about the playable area and UI needed for your game. For example, a portrait-orientation game with on-screen buttons may have a scene view of 400×1800 units and a UI overlay of 400×100 units.
Setting Pixels per Unit for Common Asset Types
With canvas sizes defined, appropriate pixels per unit values for different game elements can be determined to maximize image quality and performance.
Character Sprites
Character sprites are a major visual focus and their clarity directly impacts the player’s experience. Use the smallest dimension of the scene view canvas (likely height in portrait orientation) to find an appropriate pixels per unit value.
For example, with a scene height of 1800 units, setting pixels per unit to 48 ensures a 36 pixel tall character will be about 75 units tall, occupying a reasonable amount of screen space at a sharp, unintended quality.
Environment Art
Backdrops and environments typically feature more detail and complexity than characters. Scaling them up by using a lower pixels per unit value makes features clearer without overly magnifying pixels.
Continuing the previous example, an environment art pixels per unit of 24 causes a 72 pixel tall tree to appear 180 units tall, standing out clearly against other elements.
UI Elements
UI elements should match the size of characters and scene elements as closely as possible. Using the same or very similar pixels per unit values helps achieve clean integration and scaling.
If character sprites look best at 48 pixels per unit, maintaining that same value or going up to 64 pixels per unit will keep UI buttons, menus, and icons appropriately proportioned.
Finding the Sweet Spot for Your Game’s Visual Style
The ideal pixels per unit setting comes down to the interplay of your game’s visual style, target platforms, and performance needs. Playtesting across different device resolutions while iterating on pixels per unit values is key for finding the “sweet spot”.
Testing on Target Device Resolutions
Test your game on the minimum, average, and maximum target device resolutions expected for your players. For a pixel-art style 2D mobile game, that may span iPhone SE to iPhone XS Max-sized displays.
Examine how clarity and quality of key assets changes across platforms, and choose pixels per unit values that maximize visible detail without overmagnifying on high resolution devices.
Considering Effects on Memory and Performance
Higher pixels per unit values require larger asset sizes and texture dimensions, increasing memory usage and affecting performance. These factors are especially critical for mobile games with limited resources.
Profile memory utilization, draw calls, and frame rates to find the best balance between quality and performance for target devices. Tune pixels per unit alongside compression, batches, textures atlases and other optimizations.
Adjusting Pixels per Unit During Development
As a game evolves over development, alterations to visual style, assets, and gameplay may necessitate tweaking the pixels per unit values in a scene.
For example, swapping to a more detailed character model may require reducing pixels per unit to better showcase the upgraded art. Similarly, cutting elaborate backgrounds in favor of a simpler style could allow increasing pixels per unit for better performance.
Treat pixels per unit as a global setting tied to your game’s vision that may need refinement until the final stages of polishing a game.
Example Pixels per Unit Calculations
For a pixel-art style 2D mobile game…
- Scene View Canvas Size: 400×1800 units
- UI Canvas Size: 400×100 units
- Character Height: 36 pixels
- Environment Height: 72 pixels
- Target Devices: iPhone SE to iPhone XS Max
Therefore…
- Character Pixels Per Unit = 48 (36 pixel character is 75 units tall)
- Environment Pixels Per Unit = 24 (72 pixel environment is 180 units tall)
- UI Pixels Per Unit = 48 (matches characters for clean integration)
Testing reveals clear detail on all assets across target devices while keeping stable frame rate and memory utilization.