/// <summary> 获取最近点的索引,如果点列表长度为0时,则返回-1。 </summary> private int GetClosestPointIndex() { int closestIndex = -1; Vector3[] vertices = TransformUtil.CovertTransformsToVertices(m_points); var polyLine = GeomUtil.GetClosestPolyLineToPoint(transform.position, vertices, m_isClosed);//获取距离当前点最近的边 if (polyLine.startIndex > -1 && polyLine.endIndex > -1) { closestIndex = m_isReverseOnStart ? polyLine.startIndex : polyLine.endIndex; } return(closestIndex); }