unity删除父物体下所有子物体对象

GameObject father = GameObject.Find("CollidGroup");
int childCount = father.transform.childCount;
for (int i = 0; i < childCount; i++){
  Object.Destroy(father.transform.GetChild(i).gameObject);
}

 

posted @ 2021-11-03 10:06  盛世芳华  阅读(813)  评论(0编辑  收藏  举报