Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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
3
Question by dlerozeun · Jun 30, 2010 at 08:34 AM · 3dtext

Get 3D Text size

AFAIK, there is no direct access to the world size of a Text Mesh as it is possible in a regular Mesh through the "bounds" object. It is not possible to compute it from vertices data neither as there is also, no access to mesh data.

Is there already something that I am missing?

I need this for 3D HUD resizing according to content. For the moment I use the GUIstyle.CalcSize to get the text size in pixels, then use a magic scale factor to get the text world size. But this factor seems to depend on the font and also font size. Get the bounds of the TextMesh would be infinitely more simple.

Any help (hack) would be greatly appreciated! Thanks!

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 Case23 · Jun 30, 2010 at 09:52 AM 0
Share

Interesting question. I hope you get an answer!

1 Reply

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

Answer by Scott Kerr · Aug 23, 2010 at 09:20 AM

Hey, I know it's a bit late but I spent ages trying to figure this out too.

Eventually a found a way which while pretty hacky is the most elegant way I've found so far.

The Renderer component has a Bounds variable used for visibility culling which basically equates to a bounding box of the contents. You can use this to get the size of the TextMesh from the Renderer attached to the same object.

Here's some sample code of using it for raycasting:

public void MouseOver()
{
    Bounds bounds = renderer.bounds;
    Ray ray = camera.ScreenPointToRay(Input.mousePosition);
    return bounds.IntersectRay(ray);
}

You can get the size of the text from the Bounds.size variable.

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 dlerozeun · Aug 27, 2010 at 08:55 AM 0
Share

Yes I have finally figure it out too but forgot to update this question. I never realized that this information was duplicated in $$anonymous$$esh and Renderer components! Fortunately it is. Thanks anyway! :)

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

No one has followed this question yet.

Related Questions

why 3d text not affected by fog 3 Answers

Locking the cursor in the center of the screen 1 Answer

3D Text Component hide from behind 0 Answers

Getting Camera on mouse click of a 3d text 1 Answer

Add a 3D text imprint to an Object/Mesh, export as OBJ. Possible? 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