- Home /
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?
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
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;
Your answer

Follow this Question
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