比如清除ARACP这个物体的所有子物体。
for (int i = 0; i < ARACP.transform.childCount; i++) {
Destroy (ARACP.transform.GetChild (i).gameObject);
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ClearAll : MonoBehaviour {
// Use this for initialization
void Start () {
for (int i = 0; i < this.transform.childCount; i++) {
Destroy (this.transform.GetChild (i).gameObject);
}
}
// Update is called once per frame
void Update () {
}
}
运行的结果如下