I am trying to do something slightly convoluted and my inexperience with Unity is proving my task to be very difficult.
I have several spheres in my scene and I want a GUItext to appear over each one when the player hovers the mouse over it. Essentially when the sphere is being hovered over I need to make the GUItext visible and parent it to the sphere that the mouse is hovering over, and I need the text the GUItext is displaying to match the name of the sphere.
All this could easily be done in the inspector, but unfortunately most everything in the scene is being created dynamically, so that throws a wrench into things. Any guidance would greatly appreciated.
Oh, and I'm doing all of this in C#.
asked Jul 19 '11 at 11:01 PM
You can't parent GUIText objects to anything, because they use viewport space, whereas 3D objects use world space. (Well, technically you can parent them, but it's useless because of the incompatible coordinates.) Use a script with WorldToViewportPoint (see here for an example).
answered Jul 20 '11 at 01:26 AM
If you're doing it in script, you can just use transform.parent = TheGameObject.transform
simple as that really
answered Jul 20 '11 at 12:37 AM