1.当删除后的父物体当前帧不再被使用的时候,可以用Destroy进行删除
int i = 0;
while(i < transform.childCount)
{
Destroy(transform.GetChild (i++).gameObject);
}
2.当父物体作为模板进行创建,这时候删除子物体后马上就要使用,则用DestroyImmediate
while (transform.childCount > 0)
{
DestroyImmediate(transform.GetChild(0).gameObject);
}