根据游戏对象的名字查找 transRoot 目录下相应的的 transform

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
Transform Find(Transform transRoot, string childName)
{
Transform ret = null;
for (int i = 0; i < transRoot.childCount; i++)
{
Transform child = transRoot.GetChild(i);
if (child.name == childName)
{
ret = child;
break;
}

ret = Find(child, childName);
if (ret != null)
{
break;
}
}
return ret;
}
1
2
3
4
for (int i = 0; i < allBonesNames.Count; ++i)
{
allBones.Add(Find(rootTrans, allBonesNames[i]));
}

End.