How To Destroy All Children

[Solved] How To Destroy All Children | Sql - Code Explorer | yomemimo.com
Question : how to destroy all children

Answered by : wrong-warbler-k8h3vd43inbd

public void ClearChildren() { Debug.Log(transform.childCount); float i = 0; foreach (Transform child in transform) { i += 1; DestroyImmediate(child.gameObject); } Debug.Log(transform.childCount);
}

Source : https://stackoverflow.com/questions/46358717/how-to-loop-through-and-destroy-all-children-of-a-game-object-in-unity | Last Update : Tue, 23 Mar 21

Question : how to destroy all children

Answered by : wrong-warbler-k8h3vd43inbd

while (transform.childCount > 0) { DestroyImmediate(transform.GetChild(0).gameObject);
}

Source : https://stackoverflow.com/questions/46358717/how-to-loop-through-and-destroy-all-children-of-a-game-object-in-unity | Last Update : Tue, 23 Mar 21

Answers related to how to destroy all children

Code Explorer Popular Question For Sql