How do I find all children gameObjects of a parent (sub included: parent-child-children..) and assign it to a gameObject?
The below script finds all the children gameObjects of their current parent but does not find the sub children gameObjects of the found children.
public GameObject parent;
private GameObject AssignedChild;
foreach (Transform eachChild in parent.transform)
{
if (eachChild.gameObject.tag == "TagOfTheObject")
{
//assign the tagged GameObject to "AssignedChild" GameObject
AssignedChild = eachChild.gameObject;
}
}