Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by AjayKhara · Jan 23, 2014 at 09:50 AM · camerarenderviewportrect

Changing the Camera viewport rect results in resizing the objects rendered by the specific camera ?

I am using more than one camera in a game, each camera has different viewport.

All cameras viewports are set in such a way that they all can render certain objects. at the same point.

Now, while changing the viewport rect of a camera, sometimes the objects rendered by the camera are re-sized(Meaning : Shown smaller or larger on the screen, not actually re-sized).

When the viewport width is changed, the size remains the same. but changing the viewport height affects the size.

All camera's are orthographic. What should I do so that the size of the objects shown remains the same irrespective of the camera viewport ?

Thanks.

Case 1 : This does not change the size.

 gameCamera1.rect = new Rect(0,0,0.5f,1);
 gameCamera2.rect = new Rect(0.5f,0,0.5f,1);
 

Case 2 : This does change the size.

 gameCamera1.rect = new Rect(0,0,1,0.5f);
 gameCamera2.rect = new Rect(0,0.5f,1,0.5f);
 

You can see these images. To get the idea more clear.! In Image "1" the size is perfect, in Image "2" the objects have shrink.

![alt text][1]

1.png (136.5 kB)
2.png (119.9 kB)
Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Benproductions1 · Jan 23, 2014 at 10:32 AM 1
Share

In order to have scalable screen sizes, most rendering engines scale vertically. If you want to prevent this in a way in which scale is preserved when the screen size is changed, then you need to alter the field of view to match what you want.

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by gfoot · Jan 23, 2014 at 12:01 PM

If you just want the size to match, add something like this to a script on your camera:

 public void LateUpdate()
 {
     camera.orthographicSize = FullScreenOrthographicSize * camera.rect.height;
 }

where FullScreenOrthographicSize is a tweakable parameter that's equivalent to the orthographicSize you would use if the camera's viewport covered the whole screen. Then for smaller viewports the camera's orthographicSize gets scaled down appropriately.

If you put this in a script of its own with [ExecuteInEditMode] then it'll be easy to see the effect in the editor, and tweak the FullScreenOrthographicSize value how you want it.

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image AjayKhara · Jan 23, 2014 at 05:55 PM 0
Share

Thanks a lot.

avatar image Rayeloy AjayKhara · Apr 18, 2019 at 05:05 AM 0
Share

what about perspective projection cameras ins$$anonymous$$d of orthographic? could you help me out with that?

Your answer

Hint: You can notify a user about this post by typing @username

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

Answers Answers and Comments

21 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How does the aspect ratio work? 0 Answers

Wipe transition between two cameras 1 Answer

Centering Camera Viewport Rect? 1 Answer

Display all scene cameras in another camera? 1 Answer

How do I render only a part of the cameras view? 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges