// preview
        protected void Preview(Vector3 position, BGCurve curve, ref float toLast, ref float toFirst)
        {
            var settings = overlay.Editor.Settings;

            //show point
            BGEditorUtility.SwapHandlesColor(settings.SphereColor, () => Handles.SphereCap(0, position, Quaternion.identity, BGEditorUtility.GetHandleSize(position, ScalePreviewPoint)));

            //create a point
            var newPoint = BGNewPointPositionManager.CreatePoint(position, curve, settings.ControlType, settings.Sections, out toLast, out toFirst, false);

            //show controls
            if (newPoint.ControlType != BGCurvePoint.ControlTypeEnum.Absent)
            {
                PreviewControls(settings, position, newPoint.ControlFirstWorld, newPoint.ControlSecondWorld);
            }

            if (curve.PointsCount == 0)
            {
                return;
            }

            BGEditorUtility.SwapHandlesColor(BGCurveSettingsForEditor.ColorForNewSectionPreview, () =>
            {
                // last To new
                DrawSection(curve[curve.PointsCount - 1], newPoint, settings.Sections);

                AdditionalPreview(newPoint);

                // new To zero
                if (curve.Closed)
                {
                    DrawSection(newPoint, curve[0], settings.Sections);
                }
            });
        }
        //see base class for description
        internal override bool Seize(Event currentEvent, ref Vector3 position, ref string message)
        {
            if (!Comply(currentEvent))
            {
                return(false);
            }


            Vector3 intersectionPosition;
            Plane   plane;


            if (currentEvent.type == EventType.mouseDown && currentEvent.control && currentEvent.button == 0)
            {
                //Mouse down for some action
                var curve    = overlay.Editor.Curve;
                var settings = overlay.Editor.Settings;

                Cast(currentEvent, HandleUtility.GUIPointToWorldRay(currentEvent.mousePosition), out intersectionPosition, out message, out plane);

                if (message != null)
                {
                    BGCurveEditor.OverlayMessage.Display(message);
                }
                else
                {
                    position = intersectionPosition;
                    BGCurveEditor.AddPoint(curve,
                                           BGNewPointPositionManager.CreatePoint(intersectionPosition, curve, settings.ControlType, settings.Sections, true),
                                           curve.PointsCount);
                }
                overlay.EventCanceller = new BGEditorUtility.EventCanceller();
                return(true);
            }


            if (!(currentEvent.type == EventType.Repaint && currentEvent.control || currentEvent.type == EventType.MouseMove && currentEvent.control))
            {
                return(false);
            }

            var ray = HandleUtility.GUIPointToWorldRay(currentEvent.mousePosition);

            Cast(currentEvent, ray, out intersectionPosition, out message, out plane);

            position = intersectionPosition;

            if (message != null)
            {
                return(true);
            }

            Animation(plane, ray, swayTransition);

            //preview
            float toLast = -1, toFirst = -1;

            Preview(intersectionPosition, overlay.Editor.Curve, ref toLast, ref toFirst);

            //distance
            message = BGSceneViewOverlay.ToOk("MouseClick to add a point\r\n") +
                      //to last
                      (toLast < 0 ? "First point is ready to go!" : "Distance to last=" + toLast) +
                      //to first
                      (toFirst < 0 ? "" : ", to first=" + toFirst);
            return(true);
        }
 //default implementation adds a point to the spline's end
 protected virtual void AddPoint(BGCurve curve, Vector3 intersectionPosition, BGCurveSettings settings)
 {
     BGCurveEditor.AddPoint(curve,
                            BGNewPointPositionManager.CreatePoint(intersectionPosition, curve, settings.ControlType, settings.Sections, true),
                            curve.PointsCount);
 }
 protected virtual BGCurvePoint CreatePointForPreview(Vector3 position, BGCurve curve, out float toLast, out float toFirst, BGCurveSettings settings)
 {
     return(BGNewPointPositionManager.CreatePoint(position, curve, settings.ControlType, settings.Sections, out toLast, out toFirst, false));
 }