x


Modify Camera pixelWidth and pixelHeight

How do I modify Camera's read only fields pixelWidth and pixelHeight? I intend to configure my camera to contain 1024 pixels in width and 768 pixels in height. Thanks! :D

more ▼

asked May 18 '12 at 08:56 AM

brain56 gravatar image

brain56
29 7 12 16

(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first
more ▼

answered May 18 '12 at 11:12 AM

RoflHarris gravatar image

RoflHarris
971 5 8 13

There is also this which you can use to set the pixel rect for the camera http://unity3d.com/support/documentation/ScriptReference/Camera-pixelRect.html

May 18 '12 at 11:17 AM RoflHarris

I'm sorry, but that doesn't answer my question. You refer to changing the resolution of the screen, not the camera. I want to change these values:

http://unity3d.com/support/documentation/ScriptReference/Camera-pixelWidth.html

http://unity3d.com/support/documentation/ScriptReference/Camera-pixelHeight.html

Thank you. :D

Jun 07 '12 at 07:08 AM brain56

I dont think that it will get modified. These values are read only.

Jun 07 '12 at 07:19 AM hirenkacha

Is that so? Can you recommend a workaround to my problem? I want to use ScreenToViewportPoint() and get an accurate translation given an arbitrary position, but since the values of pixelWidth and pixelHeight are fixed, I can't do it.

Jun 08 '12 at 05:02 AM brain56
(comments are locked)
10|3000 characters needed characters left

If you're still looking for the answer, this worked for me:

camera.rect = Rect((Screen.width-512.0)/Screen.width,(Screen.height-256.0)/Screen.height,384.0/Screen.width,96.0/Screen.height);

That positions it at 512px left of the right edge and 256px below the top, 384px wide and 96px tall. You can of course adjust all the numbers to whatever you want.

more ▼

answered Oct 15 '12 at 08:44 PM

Zherynn gravatar image

Zherynn
1

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x2983
x83

asked: May 18 '12 at 08:56 AM

Seen: 1277 times

Last Updated: Oct 15 '12 at 08:44 PM