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 TSI25 · Oct 12, 2014 at 09:18 PM · ngui

Display ngui label over gameobject

Very straightforward- im trying to spawn an ngui label over a gameobject's position. Heres the code I'm using to get that to happen...

 public void ComplementPlayer(GameObject prefab, Vector3 position)
         {
             Vector3 newPos = Camera.main.WorldToScreenPoint (position);
 
             Vector3 anotherNewPos = uiCamera.ScreenToWorldPoint (newPos);
 
             Debug.Log (newPos + "\n" + anotherNewPos);
 
             GameObject go = NGUITools.AddChild(gameObject, prefab);
 
             currentComplement = go;
 
             go.transform.localPosition = newPos;
             StartCoroutine (Despawn(go));
         }
 
 

im using world to screen point which i what ive seen all the other answers reference but for some reason it just isnt quite working. The ngui label just spawns way off screen. I'm sure its something simple that I'm doing wrong but can someone point me in the right direction on this?

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 b1gry4n · Oct 12, 2014 at 10:31 PM 0
Share

I suggest investing in http://www.tasharen.com/forum/index.php?topic=997.0

I was trying to do the exact same thing as you and failing. Theres something about the localposition of ngui elements and worldtoscreenpoint that gets messed up.

Getting the hudfollow solved my issues. You simply attach a UIFollowTarget script to the label's gameobject, set the in game target, and it will follow. pretty simple to use

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by sumit9236 · Oct 13, 2014 at 07:25 AM

After disabling uiroot in editor and add panel in gameobject after that you create ngui label into that panel.With out disabling uiroot you can not able to add panel in gameObject;

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

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

Related Questions

Problems With NGUI on MAC 1 Answer

NGUI Texture 0 Answers

NGUI Buttons 2 Answers

How to keep raycast lined up with main camera & cross hair center 1 Answer

Draw Graph with Vectrosity in NGUI window 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