Destroying all child objects

I have a prefab which has some child objects.
Some of the child objects contain some child objects too.
You can see that in the picture.
1009112--37364--$001.png
I want to destroy it completely.
How is it possible ?

Thanks in advance.

var children : GameObject[ ]; // Use the inspector to populate the array.

function DestroyAll(){
for(var child in children)
Destroy(child);
}

When you “Destroy” a game object, all children are automatically destroyed with it. If you only want to destroy the children ,but not the root object - you need to loop through them via a for loop like…

void DestroyAll(){
    // If you want to destroy the parent, it's as simple as
    Destroy(gameObject);
    
    // If you only want to destroy the children, it gets a bit more complicated
    foreach(Transform child in transform){
        Destroy(child.gameObject);
    }
}

Generally speaking, if you can avoid setting up things in the inspector - it’ll save you a ton of time (and even more time when it comes to debugging).