camera width zoom

hi guys , beleave that its nearly two days that im searching but i cant find a solution for my problem , so please help me if you can …
im using an orthographic camera in a 2d side game , and i just want zoom in/out the camera in width not in height when i use this code

thisTransform.camera.orthographicSize = Mathf.Lerp (thisTransform.camera.orthographicSize ,.007 + thisTransform.camera.orthographicSize, Time.time);

the camera zooms out in height too and some part of sky is shown , that i dont want , i just need show the more area of the earth ,
also when i use this code

thisTransform.camera.rect = Rect (0, 0, 1, .5);	

the output comes out from full screen mode , so would anybody tell me that how can i modify the width ratio of the camera without modifying the height…
thanx alot , and alot more

If you zoom out in width only while keeping the same camera rect, the image will get horizontally compressed: objects will appear thinner and taller than they actually are - is this what you're actually trying to do?

no i dont want that , for example i just wanna show a wider range of the sea while the sky area is fix ,now the width and height of camera rect are equal and i wanna increase the width of the rectangle withought changing the height

is there anybody in there ...? just nod if you can hear me....

i dont know http://docs.unity3d.com/Documentation/ScriptReference/Camera-aspect.html

2 Answers

2

You cannot do that with an orthographic camera - you are actually setting the height and the width is calculated from the viewport size.

It sounds to me like what you need is two cameras - one to render the sky (with lower depth than the other one) and one to render everything else. Set the second camera to clear nothing.

And clearly don't change the orthographic size of the sky camera...

thanx its a very very good solution , and again tanx

Could you tick it as correct?

Not sure, but if it in fullscreen mode try changing screen resolution aspect ratio by changing screen height or width - Screen.SetResolution (w, h, true);