# What is the relationship between camera size, units, mesh size and resolution?

 0 When I'm working with an orthographic camera (doing 2D) I keep running into this issue where it would be great to know the math behind the relationship of the camera size and the units in unity space.For example, if I know I'm in 1024x768 resolution, and my camera size is 1, and I want a mesh that completely fills up the screen exactly, how do I calculate it's dimensions?And if I switch to 960x640 resolution, how do I know how to adjust the camera and resize the mesh to fit the new resolution exactly? What if the camera is now size 1.2? etc.I know there has to be some math that should be nailed to my wall that I can use to do these calculations. more ▼ asked Oct 06 '11 at 07:35 PM stromdotcom 1 ● 1 ● 1 ● 3 add new comment (comments are locked) 10|3000 characters needed characters left ▼ Viewable by all users

 0 The height is 2 * size, and the width is height * aspect. You can calculate them with these instructions: ``` var height = 2*Camera.main.orthographicSize; var width = height*Camera.main.aspect; ``` more ▼ answered Oct 06 '11 at 10:58 PM aldonaletto 41.3k ● 16 ● 42 ● 195 Ok, this makes sense. And then everything just scales to the resolution I assume? So if I have resolution set to 1024x768, then I can assume that 2m in unity units = 768 pixels in pixel space? If so, will it always scale by height? Oct 06 '11 at 11:27 PM stromdotcom Yes, height is the "official" screen measure in Unity - height is directly related to the Size (or orthogonalSize), and width is related to height. Depending on what you need to do, maybe it's a better idea to use Camera.main.ScreenToWorldPoint to convert pixel to world coordinates. This function receives a parameter Vector3 where x and y are the pixel coordinates and z is the distance from the camera, and returns the corresponding point in the 3D world. The inverse function also exists, WorldToScreenPoint: it converts a 3D world point to pixel coordinates x and y (the z value returned is the distance from the camera) Oct 07 '11 at 12:22 AM aldonaletto add new comment (comments are locked) 10|3000 characters needed characters left ▼ Viewable by all users
 0 The Orthographic size is the visible area from center of the screen (read: half height) to the top in unity units (1 unity unit = 1m).So if you have a orthographic size of "1" it will show exactly 2 units height (2 meters). So if you have a standard cube (Menu GameObject > Create Other > Cube), then it will be exactly half the screen height, because the default is 1x1x1 units. more ▼ answered Oct 06 '11 at 10:46 PM Tseng 1.5k ● 6 ● 8 ● 23 add new comment (comments are locked) 10|3000 characters needed characters left ▼ Viewable by all users
 0 The solution isn't scale every object in your scene, in fact is "re-size" the projection of the camera according to a specific aspect-ratio, take a look this: for me is THE SOLUTION !!! http://gamedesigntheory.blogspot.com/2010/09/controlling-aspect-ratio-in-unity.html more ▼ answered Jan 21 at 04:42 AM add new comment (comments are locked) 10|3000 characters needed characters left ▼ Viewable by all users

By Email:

Topics:

x210
x31
x20

asked: Oct 06 '11 at 07:35 PM

Seen: 5047 times

Last Updated: Jan 21 at 04:43 AM