unity3d 返回多物体中心点

public static Vector3 GetCenter(List renders, Vector3 center)
        {
            Bounds bounds = new Bounds(center, Vector3.zero);

            foreach (Transform child in renders)
            {

                bounds.Encapsulate(child.GetComponent().bounds);

            }


            return bounds.center;
        }

center=每个物体中心点相加  / 数组内物体个数 

你可能感兴趣的:(unity3d,中心点坐标)