- Home /
GetComponentInChildren by name
I have an object
public GameObject object;
What I need is to find it in a gameobject.
The way my prefab looks like
Parent
Child(one)
Child(two)
What I need is to find the child with the name two and set it as "object".
Preferred in c#, but js is fine too.
Thanks
Comment
Answer by by0log1c · Mar 05, 2011 at 04:59 AM
EDIT: After re-reading the question, I'm less certain as to what you want to do. So here's a few JS example:
//find a Transform children in current GameObject aTransform = transform.Find("LeftShoulder/Arm/Hand/Finger");
//access an object in a component script aVariable = GetComponent(theScript).aValue;