/// <summary> /// 判断点point是否在矩形内 /// </summary> public static bool IsPointInRectangle(Vector3 point, Vector3 rectA, Vector3 rectC, Vector3 rectB, Vector3 rectD) { Vector3 vector = rectC - rectA; float size = -(vector.magnitude / 2f); vector = Math3d.AddVectorLength(vector, size); Vector3 linePoint = rectA + vector; Vector3 vector2 = rectB - rectA; float num = vector2.magnitude / 2f; Vector3 vector3 = rectD - rectA; float num2 = vector3.magnitude / 2f; Vector3 a = Math3d.ProjectPointOnLine(linePoint, vector2.normalized, point); float magnitude = (a - point).magnitude; a = Math3d.ProjectPointOnLine(linePoint, vector3.normalized, point); float magnitude2 = (a - point).magnitude; return(magnitude2 <= num && magnitude <= num2); }