Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

How To: Pixel Perfect 2D in Unity (UPDATED!)

A topic by TylerCode created Jul 30, 2019 Views: 1,169
Viewing posts 1 to 1
(3 edits)

Hello All,

Haven't decided if I want to mess with GBStudio or not yet, but if I don't, I'll be using Unity. Here is how to go about setting up your scene for use on this jam. I'm not going to cover a 2D lighting version as I did for the LOWREZJAM simply because of the 4 color limit of the GB. If you're interested, you can look at my other guide


Simple steps from here on in. 

  1.  Create a new unity project and use the "2D" template. 
  2. Go up to Window > Packages to get the packages window. 
  3. Click on Advanced > Show Preview Packages 
  4. Click on "2D Pixel Perfect"
  5. Install that package. (Bottom right of the packages window)
  6. Go to your Hierarchy and select your Main Camera
  7. Now in the inspector, go to Add Component, and add the Pixel Perfect Camera component.
  8. Then set if up with these values. Make sure the Reference Resolution (x:160, y144), Upscale Render Texture (checked) and Crop Frame (checked) settings are changed DO NOT check stretch fill. CHANGE your "Assets Pixels Per Unit" to whatever you're using. In my case, I'll change it to 16 since that's what size my tilesheet is. 
  9. Import your sprites normally but make sure you change the Filter Mode to "Point (no filter)" and compression to "None"
  10. After that, you can add your assets to the scene and they will behave in a pixel perfect manner with rotation support and all. 

IMPORTANT NOTE:

Canvases do not respect image effects or anything like that so your UI elements will need to be sprites in the scene. You can use a separate render texture with them if you need to (that has helped me in the past) 
(EDIT: This isn't technically correct, you can use worldspace canvases but in my experimenting in the LOWREZJAM, I couldn't get them to stop stuttering. They wouldn't stay in a fixed position but you might be able to use a rendertexture + worldspace ui) 

Feel free to post any questions below or in the Discord.

- Happy Jamming!