How to destroy all objects that connect together ?

I have many boxs connect together.If number of boxs >= 3,it'll be destroyed all.Please help me for codes.thank so much.

It most depend on how you do it. First if you have don't have an empty on the boxes(parent) you need to. Then, there are many ways to do it, I will give you some This you only put the script into the empty object

if(box>=3){
Destroy(gameObject);
}

Then if you want to put your script in the many boxes: You can use tag:

if(box>=3){
var boxes = GameOject.FindWithTag("boxes");
Destroy(boxes);
}

You can use name:

if(box>=3){
var boxes = GameObject.Find("boxes");
Destroy(boxes);
}

Or you can only put it by manually

var boxes : GameObject;
function Update(){
if(box>=3){
Destroy(boxes);
}
}

and if you want to know how to get the integer of the number of box that are parented to this empty see childcount