0
\$\begingroup\$

I am extremely confused by the Unity editor. Look:

I have an image,

enter image description here

And I want my camera to fit it perfectly. I have achieved so by using a size property of 540:

enter image description here

Notice how the viewport rect has 1 width and 1 height. If you run this game in a Samsung Galaxy S5, the sprite will fit perfectly in your device.

Now, resize the game scene view a bit (drag the Unity window border outwards to make it grow). Let's make it bigger. Then this happens:

enter image description here

The camera "white bounds" grew bigger! And the sprite no longer fits perfectly in the Galaxy S5!

My question is, then: why did the camera's bounds grow along with the editor window, if the viewport rect property never changed (it is still at 1 width an 1 height)?

\$\endgroup\$
1
  • \$\begingroup\$ Resizing the game preview window should not have any effect on build output. Did you actually check it on the Galaxy S5? \$\endgroup\$ Feb 9, 2015 at 17:21

1 Answer 1

0
\$\begingroup\$

The ViewportRect properties are relative to the screen size. X, Y is a screen relative position to place the bottom-left corner of the camera view, and W, H is how big the camera view should be relative to the screen.

When you resize the game view, you are changing the size of the game screen, and the camera bound in the scene view adjust themselves to match.

You can set the game screen to a predefined resolution by hitting this button:

enter image description here

and selecting the desired resolution (like 1920x1080):

enter image description here

If your game view size is not the same size as the set resolution, it will downscale to fit, but will not affect your camera in your scene view.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .