Skip to main content

On Sale: GamesAssetsToolsTabletopComics
Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

How to: 2D Pixel Perfect 64x64 in Unity Sticky

A topic by TylerCode created Jul 29, 2019 Views: 3,989 Replies: 10
Viewing posts 1 to 5
Submitted (11 edits) (+5)

So, for those of us who use unity as our primary, it's always nice to find ways to do things in unity without doing anything too hacky or dirty.  I've been looking at this technique a for a few days so I want to split it into two parts. One with lighting, one without.


- Normal 2D Mode (NO LIGHTING)

Now, the way to do this before was a render texture set to 64x64 (as I did last year in my horrible 3d platformer). BUT, now there's a better way (for 2D at least) (THIS SEEMS TO WORK ON 3D TOO). 

I've looked around the last few days and found that in the package manager, if you go to the top right under advanced and click "show preview packages".



You'll now have the ability to install the 2D Pixel Perfect package. Install that bad boy and add the "Pixel Perfect Camera" component to your main camera. Then, set it up as it is shown below. 





EDIT: GO AHEAD AND SET "UPSCALE RENDER TEXTURE" TOO. You can run in edit mode to preview in the game window.


Now after you've got that, you will have a pixel perfect, 64x64 game camera. I haven't messed with it too much more but wanted to share the research I'd done with the other people excited for this jam. 







With Lighting:

If you're wanting to use the new lighting systems, you need to first setup LWRP on your project.  Sykoo has a really good video showing how to set it up. 

At 5:30ish when he has you convert your resources to the new system go ahead and do it for the whole project.


After you've done that, all you need to do is add the Pixel Perfect Camera (Experimental) to your camera and give it the same settings as above (it works almost the same but it's been updated for LWRP (and DOES NOT WORK on the default renderer) and also is the only way to get it to work on the lights.  (LWRP COMES WITH THE EXPERIMENTAL VERSION SO YOU DO NOT NEED TO GET THE OTHER PACKAGE) Also, if you are adding lighting midway through the project, make sure you still use the experimental one because otherwise lighting doesn't work.

Original Pixel Perfect Camera


Pixel Perfect Camera (Experimental)

Hard to tell the difference I know, but it's there. 

I ended up just uninstalling the normal 2D package after that. 

Happy Jamming!

Submitted(+1)

Thanks TylerC! An extra note here, if you want to do pixel perfect rotation in your project you need to go to your 'Sprite Editor' for your Sprites and change 'Pivot Unit Mode' to 'Pixels' and then also enable 'Upscale Render Texture' otherwise the pixels wont snap to thier correct positions when rotating your Sprite. Check out this source for more info -> https://docs.unity3d.com/Packages/com.unity.2d.pixel-perfect@1.0/manual/index.ht...

Submitted

Thanks for this. I haven't done any rotation stuff yet so good to know!

Hi, maybe dumb question but how would you go about doing text in a resolution like this? It seems to me like the text mesh wouldn't work very well when it's this small!

Submitted

So, I originally was going to make all the dialog boxes by hand since I only have a few I need but "él liquido#8803" on discord posted a tiny font which I plan on integrating into a simple dialog system.  I'll ask him if I can pop a link to it here but in the meantime check the Discord for the game jam and it's in the "Resources" channel. 

Submitted

Larger update to add a separate section on if you're doing lighting. Big storm here so I'll update again when power is back on and I can use my desktop instead of my laptop.

Submitted

Any tips on the player settings? Everything looks correct in Editor, but the text/scaling looks all out of whack in the standalone player. I had enforced a 64x64 player resolution but it's still not quite right. 

Submitted (1 edit)

Text in the UI?  If you're using a canvas, that's my one weakness with this method. UI  doesn't scale at all since it bypasses screen effects. Normally that's what you want but it ends up screwing things up in this case. I ended up having to use a transparent render texture with my UI elements on it. 

https://tylercode.itch.io/davinci/devlog/93800/davinci-day-7

In this post I talk about the UI being a problem. I don't have a perfect solution yet but when I do, I'll post it here for sure. I know some other people on the discord have been struggling with text too. 

As far as player settings I've just changed the web player window to 640x640 

Submitted

Thanks Tyler, sorry my question was so vague. Yea, I got the UI to scale appropriately at 64x64, I'll give the 640x640 scale a try in the webGL player to see if I can get it to scale while keeping the overall resolution the same. It's playable at 64x64 but scaled would be nicer. 

Submitted

Gotcha, yeah in that case I just try to use a 1:1 aspect and the camera script scales it pretty well. Here are my standalone and web player settings respectively. 




Submitted(+1)

That worked perfectly for me, thanks!