public bool IsControlPointVisible(int pointIndex, int controlPointIndex) { JunctionBase junction = m_spline.GetJunction(pointIndex); if (junction != null) { if (m_spline.InterpolationMode == 1) { return(false); } if (junction.GetSpline(0) != m_spline || junction.GetSplinePointIndex(0) != pointIndex) { return(false); } return(true); } if (m_spline.InterpolationMode == 0) { if (pointIndex == 0 && controlPointIndex == 0 || pointIndex == m_spline.PointsCount - 1 && controlPointIndex == m_spline.GetCtrlPointsCount(pointIndex) - 1) { return(false); } } else { if (pointIndex != 0 && pointIndex != m_spline.PointsCount - 1) { return(false); } if (pointIndex == 0 && controlPointIndex == m_spline.GetCtrlPointsCount(pointIndex) - 1 || pointIndex == m_spline.PointsCount - 1 && controlPointIndex == 0) { return(false); } } return(true); }
private void DrawSplinePoint(ref SplineEditorEventArgs args, ref SplineEditorEvent evnt, SplineRenderer splineRenderer, SplineBase spline, int j) { int mode = spline.GetPointMode(j); if (mode >= 0 && mode < splineRenderer.ControlPointColors.Length) { Handles.color = splineRenderer.ControlPointColors[mode]; } int controlPointsCount = spline.GetCtrlPointsCount(j); for (int k = 0; k < controlPointsCount; ++k) { int scale = 1; if (!splineRenderer.IsControlPointVisible(j, k)) { scale = 0; } Vector3 ctrlPosition = spline.GetCtrlPointPosition(j, k); SplinePointHandle.Result ctrlPointDragResult = DrawPointHandle(splineRenderer, ctrlPosition, scale, true); if (ctrlPointDragResult == SplinePointHandle.Result.Drag) { if (evnt == SplineEditorEvent.None) { args = new SplineEditorEventArgs(spline, j, k); evnt = SplineEditorEvent.SplineCtrlPointDrag; } } if (ctrlPointDragResult == SplinePointHandle.Result.EndDrag) { if (evnt == SplineEditorEvent.None) { args = new SplineEditorEventArgs(spline, j, k); evnt = SplineEditorEvent.SplineCtrlPointDrop; } } } float dragHandleScale = 1; if (m_draggingDragPointHandle && spline == DragSpline && DragPointIndex == j) { dragHandleScale = 0; } JunctionBase junction = spline.GetJunction(j); if (junction != null && junction != NewJunction) { bool drawSplinePoint = junction == null || spline == junction.GetSpline(0) && j == junction.GetSplinePointIndex(0); if (drawSplinePoint) { dragHandleScale = 1.5f; } else { dragHandleScale = 0; } } Handles.color = splineRenderer.SplinePointColor; Vector3 position = spline.GetPointPosition(j); SplinePointHandle.Result dragResult = DrawDragHandle(splineRenderer, position, dragHandleScale, DragSpline == null); if (dragResult == SplinePointHandle.Result.Drag) { if (evnt == SplineEditorEvent.None) { args = new SplineEditorEventArgs(spline, j); evnt = SplineEditorEvent.SplinePointDrag; } } else if (dragResult == SplinePointHandle.Result.EndDrag) { if (evnt == SplineEditorEvent.None) { args = new SplineEditorEventArgs(spline, j); evnt = SplineEditorEvent.SplinePointDrop; } } else if (dragResult == SplinePointHandle.Result.PointerOver) { m_pointerOverSpline = spline; m_pointerOverSplinePointIndex = j; m_pointerOver = true; } if (junction != null && junction != NewJunction) { Handles.color = splineRenderer.JunctionColor; JunctionHandle.Result junctionResult = DrawJunctionHandle(splineRenderer, junction.transform.position, 1); if (junctionResult == JunctionHandle.Result.Click) { evnt = SplineEditorEvent.JunctionClick; args = new SplineEditorEventArgs(junction); } else if (junctionResult == JunctionHandle.Result.Drag) { evnt = SplineEditorEvent.JunctionDrag; args = new SplineEditorEventArgs(junction); } } Handles.color = splineRenderer.SplinePointColor; SplinePointHandle.Result result = DrawPointHandle(splineRenderer, position, 1, false); if (result == SplinePointHandle.Result.EndDrag) { m_draggingDragPointHandle = false; if (evnt == SplineEditorEvent.None) { args = new SplineEditorEventArgs(spline, j); evnt = SplineEditorEvent.SplinePointCreatorDrop; } } else if (result == SplinePointHandle.Result.Drag) { m_draggingDragPointHandle = true; if (evnt == SplineEditorEvent.None) { args = new SplineEditorEventArgs(spline, j); evnt = SplineEditorEvent.SplinePointCreatorDrag; } } }