Unity 遍历子物体的两种方式

2022-12-26  本文已影响0人  114105lijia

第一种:

foreach (Transform child in parent)
{
     print(child.name);
}

第二种:

for (int i = 0; i < parent.childCount; i++) {
     Transform child = parent.GetChild(i);
     print(child.name);
}
上一篇 下一篇

猜你喜欢

热点阅读