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
2
Question by thanansan · Jul 12, 2013 at 12:25 PM · scaleplanescreensize

How to scale a plane & fit it screen..?

Get the screensize (width & height), and i want to fit my plane on screen.

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

3 Replies

· Add your reply
  • Sort: 
avatar image
4

Answer by Serotonindude · Aug 28, 2015 at 12:07 PM

ATTENTION:

If you try the correct, simplified formulas

  var height = 2.0 * Mathf.Tan(0.5 * Camera.main.fieldOfView * Mathf.Deg2Rad) * distance;
  var width = height * Camera.main.aspect;

with Unity planes consider, that a plane in Unity with the scale 1 is actually 10 units in size (wtf?!), in contrast to every other basic primitive (cube, sphere, etc...).

It took me 6 hours to find out, why i had to divide the height by 10 to match the screen.

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 danny7 · Jan 14, 2016 at 03:43 AM 0
Share

Hey, for this example, what's the distance variable? Thanks

avatar image Serotonindude · Jan 14, 2016 at 08:19 AM 0
Share

hi, the distance of the plane from the camera's origin (along the forward vector)

avatar image
3

Answer by robertbu · Jul 12, 2013 at 02:12 PM

At any given distance from the camera, you can calculate the size of a plane to fill the camera by:

 var height = 2.0 * Mathf.Tan(0.5 * Camera.main.fieldOfView * Mathf.Deg2Rad) * distance;
 var width = height * Screen.width / Screen.height;

But if you are just trying to resize a plane for different resolutions, size the plane in the editor so that the height fits then do the second line of the calculation above to get the width in a script.

Comment
Add comment · Show 1 · 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 speedacidrain · Oct 12, 2017 at 08:07 PM 0
Share

Thanks!!!!

avatar image
3

Answer by RobDaPraia · Aug 17, 2014 at 02:20 PM

Thanks a lot, small typo:

 var height = 2.0 * Mathf.Tan(0.5 * Camera.main.fieldOfView * Mathf.Deg2Rad) * distance;
 var width = height * Screen.height / Screen.width;


Should be:

 var height = 2.0 * Mathf.Tan(0.5 * Camera.main.fieldOfView * Mathf.Deg2Rad) * distance;
 var width = height * Screen.width / Screen.height;


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 robertbu · Aug 17, 2014 at 02:51 PM 0
Share

Yep. Thanks. Fixed my answer.

avatar image scottstephan · Mar 12, 2015 at 07:01 PM 0
Share

What is distance in this example?

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

20 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

Related Questions

Unity3D - Plane Scale To Pixel 0 Answers

How to scale a blob shadow plane smoothly as distance from ground changes 1 Answer

why the real size of a object doesn't show in the inspector? 0 Answers

Resize Plane? 1 Answer

Auto Scale camera depending on Screen Size - How?? 3 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