How to obtain pixel accurate placing and sizing of sprites with Orthographic camera?

Hi,
I’m interested in doing a 2D game with Unity, right now I have many pieces getting in place
but I still don’t know how I’m going to make that my sprites are drawn without scaling (if that is possible).
I’m using the Orthographic camera but using the size of 1.0 gives me small sprites on screen.
I can change that to 0.23 or something to approximate the real size but I think there must be some
rationale behind this, I don’t understand the meaning of this:
“Size: the viewport size of the camera when set to Orthographic”
In what units is this measured?

I’m really new to Unity so it’s sure I’m missing something. Please help.
Thanks!

The Camera.orthographicSize is half of the viewport’s height. Ff myCamera.orthgraphicSize is 10 and myCamera.orthographic is true, a plane with a sprite which is 10 high as viewed by the camera would be half the height of the screen. The relative width is dependent on the aspect ratio. If the camera’s aspect ratio is 3:2 (iPhone in landscape mode) then the camera’s width in game units is 15.

It is a little confusing.

For what it’s worth if you want pixel-perfect then your camera.orthographicSize should be one-half of your screen.height. In this way, if your screen.height is 640, then one game unit would correlate to one pixel

many thanks!
I’ll check right now :smile:

EDIT:
After making my camera size 640, all my plane objects got very small and disappeared, I’m exporting them from max3D for the texture mapping, so I guess this is related to the dimensions the planes for sprites are created…

Some advice in general about creating sprites on Unity?
I would really appreciate a simple guide to go from a PNG texture on hard disc, to obtaining the sprite painted on the 0,0 corner of the viewport without scaling.

What size are your planes in map coordinates? What size, in pixels, do they represent? You might have to scale them up, for example:
If you scale your viewport to 1 map unit = 1 pixel, and your plane is 1x1 map units and the sprite on the plane is 64x64 pixels, then you need to scale the plane 64 by 64 so that it is scaled correctly with the viewport.

If you want the origin to in the top left make sure it is that way prior to exporting it. I would also recommend making the plane in your modeling software the right size, 64 x 64, for example. The UV still matters of course, but with a little trial and error, you’ll get it.

Thanks to all on this thread!
I also found the discussion here helpful:
http://forum.unity3d.com/threads/25582-Displaying-exact-pixels-with-SpriteManager