- Home /
How do I get a 1:1 pixel ratio?
I'm interested in making a tile-based game in Unity. One of my main concerns with this tile game is that the game should have a 1:1 pixel ratio with the tiles, so that the tiles will always display at exactly the same size on the screen, no matter the resolution of the standalone. How do I do this? I tried this script:
@script ExecuteInEditMode()
var spriteSize = 64.0;
// set the camera to the correct orthographic size (so scene pixels are 1:1)
s_baseOrthographicSize = Screen.height / spriteSize / 2.0;
Camera.main.orthographicSize = s_baseOrthographicSize;
But it doesn't do the trick--as I change the size of the editor window, the size of my tiles onscreen changes. So, how do I get a constant 1:1 pixel ratio in my game, such that a pixel in one of my assets from Photoshop is equivalent to a pixel on the screen of my game, and will be so regardless of the game's resolution?
Answer by Al-Anselmo · Jun 29, 2012 at 03:49 AM
You need "Pixel Perfect". There are several Unity plugins that can easily provide Pixel Perfect to your project. For example, here are some that I can remember:
Sprite Manager (is free and you can get it in UnifyCommunity)
Sprite Manager 2 (is a paid and more robust version of the free one)
Ex2D
Also, there's a thread that may help you to set manually this 1:1 pixel ratio: Displaying exact pixels with SpriteManager.
Answer by SmooveB · Jun 29, 2012 at 03:58 AM
Change the filter mode on your texture to point.
But having one of those sprite handlers is really nice. I have been having great luck with 2D toolkit. It is easy to use and the creator of the thing will basically personally answer all your questions on their forum.
Your answer
Follow this Question
Related Questions
Sprite Manager sprite is visible in Scene view but not Game view 0 Answers
Problem firing projectile at mouse location 1 Answer
How would I setup my camera to get a result that looks like Enter the Gungeon? 1 Answer
How does resolution work in 2D and orthographic camera 1 Answer
3DText is rendered in front of rendertexture. (SOLVED) 1 Answer