|
I am using the ObjectLabel script from wiki unify to keep a GUI texture floating over a characters in my scene. But I cannot work out how to use that GUI textures to behave as a trigger so as to trigger animation in the character it is floating over. I have adapted the ObjectLAbel script like this
just putting a new array at the top and at the bottom trying to blend the script i would use for a conventional button. But i do not know how to make the floating texture the active GUI button. I dont know enough about scripting.
(comments are locked)
|
You did more than just add an array. The changes you made to the original code are a mess and won't work. If you make changes, test them as you go and fix any errors. Using a GUITextureIf you really want to use a GUITexture use one. If you want to add interaction, then you would implement OnMouse functions like OnMouseUp(). You only needed 3 changes to the original to make it do what you wanted:
Using a GUI.ButtonThe way the original script worked was that it would have an attached GUIText object. To use a button, you don't need to worry about the transform. This will do generally what you want if you attach it to something you want the button to follow: Thanks for your articulate and carefully explained answer skovacs. As you can see, I know nothing of scripting yet, coming from maya background. I am wondering if it possible to place the GUI.Button above a child node of the animation object ? I looked at the GetComponentInChildren function but can't work out how to apply it.
Oct 11 '10 at 11:25 AM
richardzzzarnold
In the GUITexture version of the script above, you could just drop the child into the target, or in the GUI.Button version, you could attach the script to the child directly.
Oct 12 '10 at 03:07 PM
skovacs1
You wouldn't necessarily need GetComponent... code as that is for components like scripts, colliders, rigidbodies, etc., unless you are looking for a child with a given component and maybe to get some position from the component. If you need to simply find a child, the children are contained in the parent transform and can be accessed with for(var child:Transform in target){//do something with child} as per the docs on Transform. If you need to find a child with a component, you would do var component:Type=gameObject.GetComponentInChildren(Type); //do something with component.transform.
Oct 12 '10 at 03:12 PM
skovacs1
(comments are locked)
|

You only need to format the code as code. Non-code should be left alone.
Also, please don't create and then delete and then re-post the same question when all you did was change formatting that had already been changed. That's what the edit button is for.
ok sorry about that
the third try is ok i think