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 /
This question was closed Dec 25, 2013 at 12:00 PM by ozturkcompany for the following reason:

Solved..

avatar image
0
Question by ozturkcompany · Dec 24, 2013 at 07:21 PM · screensizeplane

How to calculate the length of a plane in screen size??

Hi, i am having problems getting the length of a plane.I am getting the center of the plane via Camera.main.WorldToScreenPoint(plane.position) but cannot find a way of getting the length of one size of the plane.How would i get the bounds of this plane?Could anyone help me pls?

Comment
Add comment · Show 3
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 · Dec 24, 2013 at 07:24 PM 0
Share

Is the plane parallel to the camera or rotated at odd angles with respect to the camera?

avatar image ozturkcompany · Dec 24, 2013 at 07:28 PM 0
Share

it always face to the camera :) I use it as a gui texture.And the reason why i am using a 3d object is because of i don't want to code the gui to scale depending on different screen sizes.

avatar image iwaldrop · Dec 25, 2013 at 12:11 AM 1
Share

You should post the answer so that others can benefit from it as well.

1 Reply

  • Sort: 
avatar image
1
Best Answer

Answer by ozturkcompany · Dec 25, 2013 at 12:00 PM

The answers is the following;

 var min : Vector2;
 var max : Vector2;
 var distanceInPixels : float;
 var target : Transform;
 
 function Start ()
 {
 min = Camera.main.WorldToScreenPoint(target.renderer.bounds.min);
 max = Camera.main.WorldToScreenPoint(target.renderer.bounds.max);
 distanceInPixels = Vector2.Distance(min, max)/2;
 
 //distanceInPixels is the radius of the target.
 //You get the radius so calculate the rest..
 }
 
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 aldonaletto · Dec 25, 2013 at 02:33 PM 0
Share

NOTE: The target must have zero rotation at Start for this to work, because bounds is an AABB (Axis Aligned Bounding Box).

avatar image ozturkcompany · Dec 25, 2013 at 03:48 PM 0
Share

your avatar is awesome!! Btw i am now doing it with the following ins$$anonymous$$d of renderer bounds, now its collider.bounds.Works great!

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

Cutoff top and bottom of screen instead of sides when changing aspect ratio 1 Answer

Particles sized to screen, not scene? 1 Answer

Auto scaling GUI 3 Answers

Get Screen Size in Inches for iOS devices 0 Answers

Scaling a cube side by a plane length 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