calculating the object bounds of the group of objects

i am trying to get the center of the group of objects, so that i can center the camera to that group and have all subobjects in the screen.

here is the code i am using:

var bound : Bounds= new Bounds(Vector3.zero,Vector3.zero);
//all objects in the group have colliders, so i am using colliders to get bounds
var Colliders = target.GetComponentsInChildren(Collider);

for(var collider : Collider in Colliders){
    //if members are not tagged group or microlabel since these are just groups
    if(collider.tag!="group" || collider.tag!="microlabel"){
        bound.Encapsulate(collider.bounds);
    }
}

//print the center and size of the new bounding box
Debug.Log("center: " + bound.center.ToString() + " size: " + bound.size.ToString());

//test the center of bounding box by creating the sphere with that position
var sphere : GameObject=GameObject.CreatePrimitive(PrimitiveType.Sphere);

sphere.transform.position=bound.center;
//make sphere smaller so it fits the scene and marks more precisely the position
sphere.transform.localScale=Vector3(0.2,0.2,0.2);

this works fine for group of groups of objects, but it does not calculate the group that only holds objects i have offset by the y axis, what to do? maybe i am missing something? how to calculate this type of thing properly?

thanks

EDIT:

ok i guess that i should use the mesh.bounds instead of collider bounds. it is harder to get those i think. can somebody help me replace collider bounds with mesh.bounds in the code i provided. any help appreciated!

If you want to use the mesh.bounds, then you need to do something like this:

var filters = target.GetComponentsInChildren(MeshFilter);

for(var filter : MeshFilter in filters)
{
    //if members are not tagged group or microlabel since these are just groups
    if(filter.tag!="group" || filter.tag!="microlabel")
    {
        bound.Encapsulate(filter.mesh.bounds);
    }
}


I think that would work. Its of the top of my head :)