Problem in working with pixel .

Hello Guys ,

I am creating a game using 3D game objects and orthographic camera . I searched a lot and got info about ScreenToWorld function . But, i want to work with all resolutions.

Following are my problem :–

  1. how to set orthographicSize ???

I found that it should be equal to ScreenHeight/2;

If i set it to ScreenHeight/2 , my objects did not get visible . It is visible at orthographic size 5.

  1. How to relate the gameobject scale to screen resolutions ???

Please guide me guys .

I’ve seen a number of posts on this issue. First you need to understand what it means. Orthographic size is 1/2 of the vertical size in world units.

  • Create a new scene
  • Move the camera to (0,0,-10) (i.e. looking down the ‘z’ axis)
  • Create a cube at the origin.
  • Set the ortiographic size to 0.5.

The window will now just display that block. That is it will display a vertical size of 0.5 * 2. It doesn’t matter what the resoution of the device you put it on, this size will always have a one-unit block filling the vertical size. As the aspect ratio of the device changes, the width will change, but the vertical display will reamin the same. Different games will handle the changing space on the sides differently.

As for what size to set, I’ve read different arguments. One experienced developer argues strongly for a size of 1.0. For my projects (and I’m by no means a expert), I like to set the size based on the resolution of one device. I pick one device that I want my app to show best. Then I set the size so that I easily get ‘pixel perfect’ or ‘pixel correct’ on that device. That is, I want the graphics on that device to show without stretching or scaling. Typically I do this at 1/100th of the pixel size. For example, I would setup the camera so that if I set the size of a one-unity plane to 10.24 x 5.12, a texture on that plane with a pixel size of 1024 x 512 would be shown without any stretching or scaling.