public static void FindAllChildToList<T>(Transform parent, List<T> list)
{
foreach (Transform child in parent)
{
T go = child.GetComponent<T>();
if (go != null)
{
list.Add(child.GetComponent<T>());
}
FindAllChildToList(child, list);
}
}
本文介绍了一个实用的Unity脚本函数,用于递归地遍历GameObject的所有子对象,并将特定类型的组件收集到一个List中。此方法提高了游戏开发中资源管理和组件操作的效率。
5356

被折叠的 条评论
为什么被折叠?



