Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 Nirvan · Nov 11, 2015 at 01:33 PM · camerauitextgizmo

UI Text in world space facing camera

I need to create simple UI tips for my objects and I wan't to make them behave like this texts here: https://youtu.be/EZHeYPxsNds?t=14m48s

I tried with text in world space and make it rotate to camera but it is visible that text is rotating to camera, it not like like part of UI, also I want to text stay always on the same size, not dependent of camera position. How can I make something like this like on the video?

This behaviour can be also described as behaviour of camera gizmo icon in editor etc. but I want it without scaling when camera is nearer like "3D icons" turned off (in "gizmo" tab).

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 allenallenallen · Nov 12, 2015 at 03:54 AM 0
Share

I don't think you should make the UI in world space.

Just store the position in world space and transform that position into screen space, and then show the texts in screen space. This way, the texts will not change sizes, yet it will always look like it's facing the camera.

1 Reply

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

Answer by Le-Pampelmuse · Nov 12, 2015 at 04:38 AM

You could use a Canvas that is set to Overlay and in a script use Camera.WorldToViewportPoint to check if the object position is on screen at any time.

If it is (if both x and y are between 0 and 1), then you can set the Text position to the Vector your check returned.

Since the Vector is Screen Space and not World Space, you position the Text at the exact position the object is rendered on screen.

Of course this would result in overlapping texts if there are multiple objects close to each other in screen space, depending on your text size and similar factors. You could do simple Vector3.Distance checks, or Physics.RayCast to deal with that if it occurs.

Hope this does what you want.

Documentation: http://docs.unity3d.com/ScriptReference/Camera.WorldToViewportPoint.html

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

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

How to make UI elements same size regardless of distance 1 Answer

world canvases z fighting or rendering in the order when camera moves around 0 Answers

UI Text position not as shown in scene view? 1 Answer

UI text vs. moving camera 1 Answer

Modify individual letters in new Unity UI Text 1 Answer


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