Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
github.com/RyanNielson/PixelCamera2D
A Pixel Perfect Camera for 2D Games in Unity.
Unity is a great engine, but it isn't perfect for 2D games that use pixel art. This can become evident when you try to rotate sprites or move sprites. Rotating sprites often results in perfectly diagonal edges that leave the pixel grid. Moving sprites can have a similar problem where pixels don't line up as expected. Check out the GIFs below in the Demo section to see examples with and without PixelCamera2D.
The setup used in PixelCamera2D
uses two camera's, a quad, and a render texture to display your game. The first camera renders an image to a render texture which is sized according to the Base Width
and Base Height
values. The second camera renders its child quad whose texture is the render texture mentioned above. This child quad is resized and scaled account to the screen width and height.
This method makes pixel art games more consistant by removing perfectly straight diagonal lines and providing better scaling and letterboxing options.
Copy the PixelCamera2D
folder into your Assets
folder.
PixelCamera2D
prefab from the PixelCamera2D/Prefabs
folder into your scene. This prefab contains the pixel camera, render camera, and rendered quad.Size
value if necessary.Base Width
and Base Height
to a value that your pixel art was designed for. This is used to determine how many pixels wide and high your game should be. This is used when determining best fit and scaling sizes.Create RenderTexture Asset
button and choose a location to save the new render texture. This is created using the given Base Width
and Base Height
, so anytime those change you should use this button. If you have an existing render texture that is the correct size from another scene, you can simply drop that into the camera's Base Texture
value in the inspector.PixelCamera2DRenderer
object.This project contains a demo in the PixelCamera2DDemo
folder. This includes an example of static sprites, moving sprites, and a line renderer to show how each behaves. It also includes a button in play mode to enable and disable PixelCamera2D
so that you can compare what your game would like with or without it.
Notice the differently sized pixels and smooth diagonal edges on the sprites and line.
The pixels are now of equal size and the diagonal lines have been pixelated.
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.