unity delete all children
Code Example - unity delete all children
foreach (Transform child in transform) {
Destroy(child.gameObject);
}
unity destroy all children
while (transform.childCount > 0) {
DestroyImmediate(transform.GetChild(0).gameObject);
}
unity remove all child
foreach (Transform child in transform) {
child.SetParent(null);
}