foreach (Transform child in transform) {
Destroy(child.gameObject);
}
public GameObject objParent;
// Destory every child game object
for (int i = objParent.transform.childCount - 1; i >= 0; i--)
{
Object.Destroy(objParent.transform.GetChild(i).gameObject);
}
foreach (Transform child in transform)
child.gameObject.SetActive(false);
while (transform.childCount > 0) {
DestroyImmediate(transform.GetChild(0).gameObject);
}
//put in any gameobject having children and enter playmode
while (transform.childCount > 0)
{
DestroyImmediate(transform.GetChild(0).gameObject);
}
void Update()
{
//put in any gameobject having children and enter playmode
foreach (Transform child in transform)
{
Destroy(child.gameObject);
}
}