使用此方法类可以在一个父物体的下面递归去查找名字为childName的子物体
public static Transform GetChild(Transform parentTF, string childName)
{
//在子物体中根据名称查找
Transform childTF = parentTF.Find(childName);
if (childTF != null) return childTF;
int count = parentTF.childCount;
for (int i = 0; i < count; i++)
{//将问题转移给子物体
childTF = GetChild(parentTF.GetChild(i), childName);
if (childTF != null)
return childTF;
}
return null;
}