public static Vector3 GetCenter(Transform tans)
{
maxBound = new Bounds();
if (tans.childCount > 0)
{
if (tans.GetChild(0).childCount > 0)
{
if (tans.GetChild(0).GetChild(0).GetComponent<Renderer>() != null)
{
maxBound = tans.GetChild(0).GetChild(0).GetComponent<Renderer>().bounds;
for (int i = 1; i < tans.childCount; i++)
{
Transform child = tans.GetChild(i);
if (child.childCount > 0)
{
Renderer render = child.GetChild(0).GetComponent<Renderer>();
maxBound.Encapsulate(render.bounds);
}
}
}
}
}
return maxBound.center;
}