Exemple #1
0
		public static Vector3 GetCenterPoint(Component[] objts)
		{
			if (objts.IsNullOrEmpty())
			{
				return Vector3.zero;
			}
			if (1 == objts.Length)
			{
				return objts[0].transform.position;
			}
			Vector3 min = objts[0].transform.position;
			Vector3 max = objts[0].transform.position;
			for (int i = 1; i < objts.Length; ++i)
			{
				var point = objts[i].transform.position;
				min = Vector3.Min(min, point);
				max = Vector3.Min(max, point);
			}
			return new Vector3((max.x-min.x)/2, (max.y-min.y)/2, (max.z-min.z)/2);
		}