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
1
Question by siaran · Mar 24, 2015 at 12:04 PM · uitextworld space

UI world space text resolution

I'm trying to make a thing where you can see an object's name (and distance to the camera) kind of floating above it. So I made a world space canvas, scaled it down, put some text on it, and got, well this:

alt text

Which looks sort-of okay, but if I move it a bit further from the camera, the text becomes completely unreadable, like this:

alt text

And I want the text to be readable from some distance, too. So...can I fix this, or do I have to go back to the old GUI system and do the good (bad?) old translate-to-screen-space, draw Label in OnGUI method? In my example the object is 30 and 50 units away from the camera, which is really not that far. (it's a 10x10x10 cube if you're wondering about the size)

I've tried messing with the Dynamic Pixels Per Unit and Reference Pixels Per Unit variables on the Canvas Scaler, but that didn't seem to make a difference.

Oh, and for the curious, the World Object UI script that's on there looks like this:

 using UnityEngine;
 using UnityEngine.UI;
 using System.Collections;
 
 public class WorldObjectUI : MonoBehaviour {
 
     public Camera worldCamera;
 
     public Image healthBar;
     //public Image shieldBar;
     public Text text;
 
     public Health health;
 
     // Use this for initialization
     void Start () {
         worldCamera = Camera.main;
     }
     
     // Update is called once per frame
     void Update () {
 
         if(health)    healthBar.fillAmount = health.currentHitPoints/health.maxHitPoints;
 
         text.text = transform.root.name + "\n" + Vector3.Distance(transform.position, worldCamera.transform.position).ToString("0.00m");
 
         transform.LookAt(worldCamera.transform.position);
 
     }
 }



(Also, for somer reason that UI looks away from my camera and I have to rotate everything on it 180 degrees on the y-axis for it to be correct. Not really important, but if someone knows what's going on there I'd appreciate it, too).

worldtext1.png (321.6 kB)
worldtext2.png (414.5 kB)
Comment
Add comment · Show 2
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 siaran · Mar 24, 2015 at 11:32 PM 0
Share

Related, does anyone know if the new UI system has a way to place a UI object in world space, but always have it drawn the same size on screen?

avatar image Teeseesee · Oct 24, 2015 at 09:17 PM 0
Share

This is a very important question for a very common scenario. Is anyone aware of any updates that are different from this?

Thank you Siaran for this btw!

1 Reply

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

Answer by siaran · Mar 26, 2015 at 01:10 AM

Well, here is one way to do it... http://blog.manapebbles.com/world-space-overlay-camera-in-unity/

Was hoping it would be easier with the new system than with the old one, but apparently not. If anyone knows of a better way I'd be glad to hear it but I guess I'll mark this as answered.

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

21 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 avatar image

Related Questions

How do you create text that can be the child of a non-canvas object? 1 Answer

New UI Text is horizontally mirrored 2 Answers

Gui text script - help 1 Answer

Fonts for commercial mobile game (Android) 1 Answer

Setting up text and images on the surface of a plane? 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