- Home /
Question by
allfader · Feb 09, 2013 at 11:51 PM ·
javascriptvariableguitexture
Finding the GuiTexture of an object
need to find the GuiTexture connected to the child of "var closest" and return it to "var myGui". Any ideas?*
My starting point:
var closest : Transform;
var myGui : GUITexture;
.....
function Update () {
myGui = GameObject.Find("Target_enemy").guiTexture;
}
Comment
Best Answer
Answer by paulaceccon · Feb 10, 2013 at 12:16 AM
var myObject : GameObject
var myGui : GUITexture;
function Update () {
myObject = GameObject.Find("Target_enemy");
if (myGui)
{
myGui = myObject.GetComponet(GUITexture);
}
}
http://docs.unity3d.com/Documentation/ScriptReference/GameObject.GetComponent.html
Your answer
![](https://koobas.hobune.stream/wayback/20220613092425im_/https://answers.unity.com/themes/thub/images/avi.jpg)