How to set up Unity3D for a pixel art game! | Ludum Dare
Save article ToRead Archive Delete · Log in Log out
2 min read · View original · ludumdare.com
This is a quick tutorial I’m putting together as a part of my warm up for Ludum Dare. Lots of people love Unity but sometimes things can take a while to do. This is one of those awkward things: pixel art.
Create a sprite
Grab your lovely pixel sprite texture and put it into a ‘Sprites’ folder in Unity. Click on the texture and set it up as follows:
- Texture Type: Sprite (2D and UI)
- Pixels Per Unit: The pixel size of your sprite, try to keep this to a power of 2 e.g.: 16, 32, 64
- Generate Mip Maps: Off
- Filter Mode: Point
Apply these settings. In 2D mode on the Unity Scene Editor, draw the sprite from the Project window to the scene. Follow the dialog for making an animation.
Create a sprite material
Create a new material in a ‘Materials’ folder. Set it up as follows:
- Shader: Sprite/Default
- Pixel Snap: On
Apply the material to your sprite by dragging it from the Project window to the sprite object in your scene.
Modify the camera
Select the ‘Main Camera’ in the Hierarchy and set the values of the ‘Camera Component’ to:
- Projection: Orthographic
- Size: Now this is the key part. Choose a screen size, for example 480×320 and stick to it. In a minute we’ll change the Game window to reflect this size. Set the size value of the camera to be Screen Height / 2 / Pixels Per Unit of your sprites.
(in this case I was using a 24×24 size sprite and a screen height of 320 which gave me 6.66666, I wasn’t happy with that so I doubled it. I would recommend not using 24×24 size sprites.)
Preparing the game window
Select the Game window and click the drop down to choose the screen aspect ratio, usually ‘Free Aspect’. Click the plus button to add a new screen setup and then enter in the screen size you chose. Give it a name and click okay. Then select that screen size.
Preparing the build output
To setup the resolution for the built version of the game, go to Edit > Settings > Player Settings and then modify the following values for the platform you want to build to:
- Default Is Native: No
- Default Screen Width: Your Screen Width
- Default Screen Height: Your Screen Height
- Display Resolution Dialog: Disabled
There may be other things you want to change such as ‘Default Full Screen’.
Try it out!
Let me know if any of that didn’t make sense. Good luck for the weekend!