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
0
Question by Reefer · Jun 05, 2014 at 12:48 PM · guitexttextmeshguilabel

GUILabel to GUIText or Textmesh

Hi everyone, I'm having a little problem with my script:

 #pragma strict
 var targetScreenPosition : Vector3;
 var Mname = "MonsterName";
 
 function Start () {
 
 }
 
 function Update () {
 
 }
 
 function OnGUI(){
     targetScreenPosition = Camera.main.WorldToScreenPoint(transform.position);
     targetScreenPosition.y = Screen.height - targetScreenPosition.y;
     targetScreenPosition.x = targetScreenPosition.x - 20;
     if(targetScreenPosition.z > 0){
     GUI.Label (new Rect (targetScreenPosition.x,targetScreenPosition.y,100,50),Mname);
     }
 }

What I'm trying to do here is an script that shows name of monster to the player always right (it turns where player goes) but the problem with this is I can't hide GUILabel's if they're behind the wall. So I would need to transform this script so it works with GUIText or Textmesh so I could hide that text if player doesnt see that current gameobject, but I dont really have no idea how to get it work with textmeshes or guitext so that those would load Mname variable as their texts.

I'm sorry if this has been an bad explanation.

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 Nerevar · Jun 05, 2014 at 12:55 PM 0
Share

Hi

$$anonymous$$aybe you can check with a raycast if there is not any object between the player and the monster before displaying the name.

0 Replies

· Add your reply
  • Sort: 

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

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

Related Questions

How can I display ligatures? (in TextMesh and/or GUIText) 0 Answers

3D Text (TextMesh) not updated/redrawn every frame (android only) 0 Answers

I want to change TextMeshProUGUI based on value of a float, but I cant seem to work it. 0 Answers

Enable ChildObject of Player with OnTriggerEnter? Or a whole different method? 0 Answers

GUI Label Text Sizing problem 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