I am looking to make a function that loops to find a child (can be a child of a child and so on). Currently, the loop only looks at the children of the game object, but not their own…
Transform Holder (string holderName) {
foreach (Transform child in transform)
if (child.name == holderName + " holder")
return child;
return null;
}
Notice : This is to loop in a list of bones, so the amount of children and sub-children is unknown.
Thanks for the help!
Transform Holder (Transform where, string holderName) {
foreach (Transform child in where)
if (child.name == holderName + " holder")
return child;
else
{
Transform tr = Holder(child, holderName);
if(tr != null)return tr;
}
return null;
}
That should work 