private Vector2 getPoint(int index) { if (IsCyclic || index < m_Waypoints2D.Count) { return(m_Waypoints2D.At(index)); } else { int offset = index - m_Waypoints2D.Count + 1; int retIndex = m_Waypoints2D.Count - offset - 1; return(m_Waypoints2D.At(retIndex)); } }
private void handleLeftMouseDown(Event evt, Vector2 mousePosition) { bool delete = evt.modifiers == EventModifiers.Control; if (!delete) { if (!m_SelectionInfo.MouseIsOverPoint) { int newPointIndex = (m_SelectionInfo.MouseIsOverLine) ? m_SelectionInfo.LineIndex + 1 : m_Target.Count; Undo.RecordObject(m_Target, "Add New Waypoint"); m_Target.Points.Insert(newPointIndex, mousePosition); m_SelectionInfo.PointIndex = newPointIndex; } m_SelectionInfo.PointIsSelected = true; m_SelectionInfo.PositionAtStartOfDrag = m_Target.At(m_SelectionInfo.PointIndex); m_NeedRepaint = true; } else { if (m_SelectionInfo.MouseIsOverPoint) { deletePointUnderMouse(); } } }