• 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 The Stick · May 18, 2015 at 07:04 PM · camera2dscreenscreenshotorthographic

Finding the right ortho size to fill the screen with an object

I have an object (with several c$$anonymous$$ldren) whose size in Unity Units I could find pretty easily (mark two corners with dummy objects and just get the Vector3.Distance of that). Presuming t$$anonymous$$s is a completely 2D application, how would I take t$$anonymous$$s abstract object and fill the screen with it by changing the orthograp$$anonymous$$c camera's Camera.orthograp$$anonymous$$cSize once?

The intent is to capture a region of the screen (read: the whole object in as best a resolution as possible) for PDF output. I've done it before using a "change and test" looping approach, but changing it once would speed the process up.

I am aware of the Pixel-perfect calculator, however the object I need to capture is very rectangular and I'm not certain how to modify t$$anonymous$$s calculator to go from "pixel-perfect" to "as large as can fit".

Comment
Add comment
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

1 Reply

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

Answer by FortisVenaliter · May 18, 2015 at 10:37 PM

I'm not sure, but I believe the orthograp$$anonymous$$c size is equivalent to the vertical size of the view in world units.

However, it should be really easy for you to play with t$$anonymous$$s and figure out for sure yourself. Unit tests are great for t$$anonymous$$s sort of t$$anonymous$$ng.

What I would do is create a new scene with an orthograp$$anonymous$$c camera and a quad. Make sure they are properly facing each other, then play with the quad scale, camera position, screen aspect ratio, and camera ortho size until you're able to find the proper correlations. Then port the info you learned from that into the code in your project, and voila.

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 The Stick · May 19, 2015 at 04:51 PM 0
Share

I was afraid I was going to have to do some guess and test at some point, but shifting it to compile-time seems to be a bit better. Already have a bit of a start on it... so yeah.

avatar image The Stick · May 19, 2015 at 08:03 PM 1
Share

Testing has come to the conclusion that finding the proper Orthographic Size for a non-square object to fill the screen is an exponential function based on the aspect ratio of the camera's rectangle... unless it's filling the screen vertically (ie a wicked-long-and-not-very-tall window), in which case it's a constant number. The exact numbers appear to depend on the aspect ratio of the object in question.

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

19 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

Related Questions

2D Camera sizing and movement 0 Answers

Orthographic camera cuts off half of screen in Web Player - resolution error? 1 Answer

Polygons clipping at edge of screen 1 Answer

Sprite relative position/scale problem with orthographic camera 0 Answers

Set camera to specify x,y in pixels? 2d 0 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