Пример #1
0
        void SceneClipEdit()
        {
            if (users.Length > 1)
            {
                return;
            }
            SplineUser user = (SplineUser)target;

            if (user.spline == null)
            {
                return;
            }
            Color col = user.spline.editorPathColor;

            Undo.RecordObject(user, "Edit Clip Range");
            double val = user.clipFrom;

            SplineEditorHandles.Slider(user.spline, ref val, col, "Clip From", SplineEditorHandles.SplineSliderGizmo.ForwardTriangle);
            if (val != user.clipFrom)
            {
                user.clipFrom = val;
            }
            val = user.clipTo;
            SplineEditorHandles.Slider(user.spline, ref val, col, "Clip To", SplineEditorHandles.SplineSliderGizmo.BackwardTriangle);
            if (val != user.clipTo)
            {
                user.clipTo = val;
            }
        }
Пример #2
0
        public override void DrawScene()
        {
            if (selectedPoints.Count == 0)
            {
                return;
            }
            if (rotateNormals)
            {
                Handles.color = new Color(Color.yellow.r, Color.yellow.g, Color.yellow.b, 0.4f);
                for (int i = 0; i < selectedPoints.Count; i++)
                {
                    Vector3 normal = points[selectedPoints[i]].normal;
                    normal *= HandleUtility.GetHandleSize(points[selectedPoints[i]].position);
                    Handles.DrawLine(points[selectedPoints[i]].position, points[selectedPoints[i]].position + normal);
                    SplineEditorHandles.DrawArrowCap(points[selectedPoints[i]].position + normal, Quaternion.LookRotation(normal), HandleUtility.GetHandleSize(points[selectedPoints[i]].position));
                }
            }
            Handles.color = Color.white;
            Quaternion lastRotation = rotation;

            rotation = Handles.RotationHandle(lastRotation, selectionCenter);
            if (lastRotation != rotation)
            {
                RecordUndo("Rotate Points");
                PrepareTransform();
                for (int i = 0; i < selectedPoints.Count; i++)
                {
                    points[selectedPoints[i]] = localPoints[selectedPoints[i]];
                    TransformPoint(ref points[selectedPoints[i]], rotateNormals, rotateTangents);
                }
                SetDirty();
            }
        }
Пример #3
0
        void FreeNormal(int index)
        {
            Handles.color = highlightColor;
            Handles.DrawWireDisc(points[index].position, points[index].normal, HandleUtility.GetHandleSize(points[index].position) * 0.25f);
            Handles.DrawWireDisc(points[index].position, points[index].normal, HandleUtility.GetHandleSize(points[index].position) * 0.5f);
            Handles.color = color;
            Handles.DrawLine(points[index].position, points[index].position + HandleUtility.GetHandleSize(points[index].position) * points[index].normal);
            Vector3 normalPos  = points[index].position + points[index].normal * HandleUtility.GetHandleSize(points[index].position);
            Vector3 lastNormal = points[index].normal;

            normalPos  = SplineEditorHandles.FreeMoveCircle(normalPos, HandleUtility.GetHandleSize(normalPos) * 0.1f);
            normalPos -= points[index].position;
            normalPos.Normalize();
            if (normalPos == Vector3.zero)
            {
                normalPos = Vector3.up;
            }
            if (lastNormal != normalPos)
            {
                RecordUndo("Edit Point Normals");
                points[index].normal = normalPos;
                Quaternion delta = Quaternion.FromToRotation(lastNormal, normalPos);
                for (int n = 0; n < selectedPoints.Count; n++)
                {
                    if (selectedPoints[n] == index)
                    {
                        continue;
                    }
                    points[selectedPoints[n]].normal = delta * points[selectedPoints[n]].normal;
                }
            }
        }
Пример #4
0
        public override void DrawScene()
        {
            base.DrawScene();
            if (spline.isClosed)
            {
                return;
            }
            Camera editorCamera = SceneView.currentDrawingSceneView.camera;

            for (int i = 0; i < availableMergeComputers.Length; i++)
            {
                SplineDrawer.DrawSplineComputer(availableMergeComputers[i]);
                SplinePoint startPoint = availableMergeComputers[i].GetPoint(0);
                SplinePoint endPoint   = availableMergeComputers[i].GetPoint(availableMergeComputers[i].pointCount - 1);
                Handles.color = availableMergeComputers[i].editorPathColor;

                if (SplineEditorHandles.CircleButton(startPoint.position, Quaternion.LookRotation(editorCamera.transform.position - startPoint.position), HandleUtility.GetHandleSize(startPoint.position) * 0.15f, 1f, availableMergeComputers[i].editorPathColor))
                {
                    Merge(i, MergeSide.Start);
                    break;
                }
                if (SplineEditorHandles.CircleButton(endPoint.position, Quaternion.LookRotation(editorCamera.transform.position - endPoint.position), HandleUtility.GetHandleSize(endPoint.position) * 0.15f, 1f, availableMergeComputers[i].editorPathColor))
                {
                    Merge(i, MergeSide.End);
                    break;
                }
            }
            Handles.color = Color.white;
        }
Пример #5
0
        protected virtual void KeyHandles(SplineSampleModifier.Key key, bool edit)
        {
            if (!isOpen)
            {
                return;
            }
            bool   changed = false;
            double value   = 0f;

            value = key.start;
            SplineEditorHandles.Slider(user.spline, ref value, user.spline.editorPathColor, "Start", SplineEditorHandles.SplineSliderGizmo.ForwardTriangle, 0.8f);
            if (key.start != value)
            {
                key.start = value;
                changed   = true;
            }

            value = key.globalCenterStart;
            SplineEditorHandles.Slider(user.spline, ref value, user.spline.editorPathColor, "", SplineEditorHandles.SplineSliderGizmo.Rectangle, 0.6f);
            if (key.globalCenterStart != value)
            {
                key.globalCenterStart = value;
                changed = true;
            }

            value = key.globalCenterEnd;
            SplineEditorHandles.Slider(user.spline, ref value, user.spline.editorPathColor, "", SplineEditorHandles.SplineSliderGizmo.Rectangle, 0.6f);
            if (key.globalCenterEnd != value)
            {
                key.globalCenterEnd = value;
                changed             = true;
            }

            value = key.end;
            SplineEditorHandles.Slider(user.spline, ref value, user.spline.editorPathColor, "End", SplineEditorHandles.SplineSliderGizmo.BackwardTriangle, 0.8f);
            if (key.end != value)
            {
                key.end = value;
                changed = true;
            }


            if (Event.current.control)
            {
                value = key.position;
                double lastValue = value;
                SplineEditorHandles.Slider(user.spline, ref value, user.spline.editorPathColor, "", SplineEditorHandles.SplineSliderGizmo.Circle, 0.4f);
                if (value != lastValue)
                {
                    key.position = value;
                    changed      = true;
                }
            }

            if (changed)
            {
                user.Rebuild();
            }
        }
Пример #6
0
        protected void DrawResult(SplineSample result)
        {
            SplineTracer tracer = (SplineTracer)target;

            Handles.color = Color.white;
            Handles.DrawLine(tracer.transform.position, result.position);
            SplineEditorHandles.DrawSolidSphere(result.position, HandleUtility.GetHandleSize(result.position) * 0.2f);
            Handles.color = Color.blue;
            Handles.DrawLine(result.position, result.position + result.forward * HandleUtility.GetHandleSize(result.position) * 0.5f);
            Handles.color = Color.green;
            Handles.DrawLine(result.position, result.position + result.up * HandleUtility.GetHandleSize(result.position) * 0.5f);
            Handles.color = Color.red;
            Handles.DrawLine(result.position, result.position + result.right * HandleUtility.GetHandleSize(result.position) * 0.5f);
            Handles.color = Color.white;
        }
        protected override void KeyHandles(SplineSampleModifier.Key key, bool edit)
        {
            if (!isOpen)
            {
                return;
            }
            bool         is2D   = user.spline != null && user.spline.is2D;
            SplineSample result = new SplineSample();
            List <SplineSampleModifier.Key> keys = module.GetKeys();

            OffsetModifier.OffsetKey offsetKey = (OffsetModifier.OffsetKey)key;
            user.spline.Evaluate(offsetKey.position, result);
            matrix.SetTRS(result.position, Quaternion.LookRotation(result.direction, result.normal), Vector3.one * result.size);
            Vector3 pos = matrix.MultiplyPoint(offsetKey.offset);

            if (is2D)
            {
                Handles.DrawLine(result.position, result.position + result.right * offsetKey.offset.x * result.size);
                Handles.DrawLine(result.position, result.position - result.right * offsetKey.offset.x * result.size);
            }
            else
            {
                Handles.DrawWireDisc(result.position, result.direction, offsetKey.offset.magnitude * result.size);
            }
            Handles.DrawLine(result.position, pos);

            if (edit)
            {
                Vector3 lastPos = pos;
                pos = SplineEditorHandles.FreeMoveRectangle(pos, HandleUtility.GetHandleSize(pos) * 0.1f);
                if (pos != lastPos)
                {
                    pos   = matrix.inverse.MultiplyPoint(pos);
                    pos.z = 0f;
                    if (is2D)
                    {
                        offsetKey.offset = Vector2.right * pos.x;
                    }
                    else
                    {
                        offsetKey.offset = pos;
                    }
                    user.Rebuild();
                }
            }

            base.KeyHandles(key, edit);
        }
Пример #8
0
        protected override void InsertMode(Vector3 screenCoordinates)
        {
            base.InsertMode(screenCoordinates);
            double percent = ProjectScreenSpace(screenCoordinates);

            editor.evaluate(percent, evalResult);
            if (editor.eventModule.mouseRight)
            {
                SplineEditorHandles.DrawCircle(evalResult.position, Quaternion.LookRotation(editorCamera.transform.position - evalResult.position), HandleUtility.GetHandleSize(evalResult.position) * 0.2f);
                return;
            }
            if (SplineEditorHandles.CircleButton(evalResult.position, Quaternion.LookRotation(editorCamera.transform.position - evalResult.position), HandleUtility.GetHandleSize(evalResult.position) * 0.2f, 1.5f, color))
            {
                RecordUndo("Create Point");
                SplinePoint newPoint = new SplinePoint(evalResult.position, evalResult.position);
                newPoint.size   = evalResult.size;
                newPoint.color  = evalResult.color;
                newPoint.normal = evalResult.up;
                SplinePoint[] newPoints  = new SplinePoint[points.Length + 1];
                double        floatIndex = (points.Length - 1) * percent;
                int           pointIndex = Mathf.Clamp(DMath.FloorInt(floatIndex), 0, points.Length - 2);
                for (int i = 0; i < newPoints.Length; i++)
                {
                    if (i <= pointIndex)
                    {
                        newPoints[i] = points[i];
                    }
                    else if (i == pointIndex + 1)
                    {
                        newPoints[i] = newPoint;
                    }
                    else
                    {
                        newPoints[i] = points[i - 1];
                    }
                }
                SplineComputer spline = dsEditor.spline;
                points      = newPoints;
                lastCreated = points.Length - 1;
                dsEditor.UpdateSpline();
                spline.ShiftNodes(pointIndex + 1, spline.pointCount - 1, 1);
                if (createNode)
                {
                    CreateNodeForPoint(pointIndex + 1);
                }
            }
        }
Пример #9
0
        protected override void KeyHandles(SplineSampleModifier.Key key, bool edit)
        {
            RotationModifier.RotationKey rotationKey = (RotationModifier.RotationKey)key;
            SplineSample result = new SplineSample();

            user.spline.Evaluate(rotationKey.position, result);
            if (rotationKey.useLookTarget)
            {
                if (rotationKey.target != null)
                {
                    Handles.DrawDottedLine(result.position, rotationKey.target.position, 5f);
                    if (edit)
                    {
                        Vector3 lastPos = rotationKey.target.position;
                        rotationKey.target.position = Handles.PositionHandle(rotationKey.target.position, Quaternion.identity);
                        if (lastPos != rotationKey.target.position)
                        {
                            user.Rebuild();
                        }
                    }
                }
            }
            else
            {
                Quaternion directionRot = Quaternion.LookRotation(result.forward, result.up);
                Quaternion rot          = directionRot * Quaternion.Euler(rotationKey.rotation);
                SplineEditorHandles.DrawArrowCap(result.position, rot, HandleUtility.GetHandleSize(result.position));

                if (edit)
                {
                    Vector3 lastEuler = rot.eulerAngles;
                    rot = Handles.RotationHandle(rot, result.position);
                    rot = Quaternion.Inverse(directionRot) * rot;
                    rotationKey.rotation = rot.eulerAngles;
                    if (rot.eulerAngles != lastEuler)
                    {
                        user.Rebuild();
                    }
                }
            }
            base.KeyHandles(key, edit);
        }
Пример #10
0
        public override void DrawScene()
        {
            bool   change       = false;
            Camera editorCamera = SceneView.currentDrawingSceneView.camera;

            for (int i = 0; i < spline.pointCount; i++)
            {
                Vector3 pos = spline.GetPointPosition(i);
                if (SplineEditorHandles.CircleButton(pos, Quaternion.LookRotation(editorCamera.transform.position - pos), HandleUtility.GetHandleSize(pos) * 0.12f, 1f, spline.editorPathColor))
                {
                    SplitAtPoint(i);
                    change = true;
                    break;
                }
            }
            SplineSample projected = spline.Evaluate(ProjectMouse());

            if (!change)
            {
                float   pointValue = (float)projected.percent * (spline.pointCount - 1);
                int     pointIndex = Mathf.FloorToInt(pointValue);
                float   size       = HandleUtility.GetHandleSize(projected.position) * 0.3f;
                Vector3 up         = Vector3.Cross(editorCamera.transform.forward, projected.forward).normalized *size + projected.position;
                Vector3 down       = Vector3.Cross(projected.forward, editorCamera.transform.forward).normalized *size + projected.position;
                Handles.color = spline.editorPathColor;
                Handles.DrawLine(up, down);
                Handles.color = Color.white;
                if (pointValue - pointIndex > spline.moveStep)
                {
                    if (SplineEditorHandles.CircleButton(projected.position, Quaternion.LookRotation(editorCamera.transform.position - projected.position), HandleUtility.GetHandleSize(projected.position) * 0.12f, 1f, spline.editorPathColor))
                    {
                        SplitAtPercent(projected.percent);
                        change = true;
                    }
                }
                SceneView.RepaintAll();
            }
            Handles.color = Color.white;
            SplineDrawer.DrawSplineComputer(spline, 0.0, projected.percent, 1f);
            SplineDrawer.DrawSplineComputer(spline, projected.percent, 1.0, 0.4f);
        }
Пример #11
0
        protected virtual void InsertMode(Vector3 screenCoordinates)
        {
            double percent = ProjectScreenSpace(screenCoordinates);

            editor.evaluate(percent, evalResult);
            if (editor.eventModule.mouseRight)
            {
                SplineEditorHandles.DrawCircle(evalResult.position, Quaternion.LookRotation(editorCamera.transform.position - evalResult.position), HandleUtility.GetHandleSize(evalResult.position) * 0.2f);
                return;
            }
            if (SplineEditorHandles.CircleButton(evalResult.position, Quaternion.LookRotation(editorCamera.transform.position - evalResult.position), HandleUtility.GetHandleSize(evalResult.position) * 0.2f, 1.5f, color))
            {
                RecordUndo("Create Point");
                SplinePoint newPoint = new SplinePoint(evalResult.position, evalResult.position);
                newPoint.size   = evalResult.size;
                newPoint.color  = evalResult.color;
                newPoint.normal = evalResult.up;
                SplinePoint[] newPoints  = new SplinePoint[points.Length + 1];
                double        floatIndex = (points.Length - 1) * percent;
                int           pointIndex = Mathf.Clamp(DMath.FloorInt(floatIndex), 0, points.Length - 2);
                for (int i = 0; i < newPoints.Length; i++)
                {
                    if (i <= pointIndex)
                    {
                        newPoints[i] = points[i];
                    }
                    else if (i == pointIndex + 1)
                    {
                        newPoints[i] = newPoint;
                    }
                    else
                    {
                        newPoints[i] = points[i - 1];
                    }
                }
                points = newPoints;
                SelectPoint(pointIndex);
            }
        }
        void DrawGroupScene(int index)
        {
            TriggerGroup group = spline.triggerGroups[index];

            for (int i = 0; i < group.triggers.Length; i++)
            {
                SplineEditorHandles.SplineSliderGizmo gizmo = SplineEditorHandles.SplineSliderGizmo.DualArrow;
                switch (group.triggers[i].type)
                {
                case SplineTrigger.Type.Backward: gizmo = SplineEditorHandles.SplineSliderGizmo.BackwardTriangle; break;

                case SplineTrigger.Type.Forward: gizmo = SplineEditorHandles.SplineSliderGizmo.ForwardTriangle; break;

                case SplineTrigger.Type.Double: gizmo = SplineEditorHandles.SplineSliderGizmo.DualArrow; break;
                }
                double last = group.triggers[i].position;
                if (SplineEditorHandles.Slider(spline, ref group.triggers[i].position, group.triggers[i].color, group.triggers[i].name, gizmo) || last != group.triggers[i].position)
                {
                    Select(index, i);
                    Repaint();
                }
            }
        }
Пример #13
0
        protected virtual void OnSceneGUI()
        {
            Node node = (Node)target;

            Node.Connection[] connections = node.GetConnections();
            for (int i = 0; i < connections.Length; i++)
            {
                DSSplineDrawer.DrawSplineComputer(connections[i].spline, 0.0, 1.0, 0.5f);
            }

            bool update = false;

            if (position != node.transform.position)
            {
                position = node.transform.position;
                update   = true;
            }
            if (scale != node.transform.localScale)
            {
                scale  = node.transform.localScale;
                update = true;
            }
            if (rotation != node.transform.rotation)
            {
                rotation = node.transform.rotation;
                update   = true;
            }
            if (update)
            {
                node.UpdateConnectedComputers();
            }

            if (addComp == null)
            {
                if (connections.Length > 0)
                {
                    bool bezier = false;
                    for (int i = 0; i < connections.Length; i++)
                    {
                        if (connections[i].spline == null)
                        {
                            continue;
                        }
                        if (connections[i].spline.type == Spline.Type.Bezier)
                        {
                            bezier = true;
                            continue;
                        }
                    }
                    if (bezier && node.type == Node.Type.Smooth)
                    {
                        if (connections[0].spline != null)
                        {
                            SplinePoint point = node.GetPoint(0, true);
                            Handles.DrawDottedLine(node.transform.position, point.tangent, 6f);
                            Handles.DrawDottedLine(node.transform.position, point.tangent2, 6f);
                            Vector3 lastPos  = point.tangent;
                            bool    setPoint = false;
                            point.SetTangentPosition(Handles.PositionHandle(point.tangent, node.transform.rotation));
                            if (lastPos != point.tangent)
                            {
                                setPoint = true;
                            }
                            lastPos = point.tangent2;
                            point.SetTangent2Position(Handles.PositionHandle(point.tangent2, node.transform.rotation));
                            if (lastPos != point.tangent2)
                            {
                                setPoint = true;
                            }

                            if (setPoint)
                            {
                                node.SetPoint(0, point, true);
                                node.UpdateConnectedComputers();
                            }
                        }
                    }
                }
                return;
            }
            SplinePoint[] points       = addComp.GetPoints();
            Transform     camTransform = SceneView.currentDrawingSceneView.camera.transform;

            DSSplineDrawer.DrawSplineComputer(addComp, 0.0, 1.0, 0.5f);
            TextAnchor originalAlignment = GUI.skin.label.alignment;
            Color      originalColor     = GUI.skin.label.normal.textColor;

            GUI.skin.label.alignment        = TextAnchor.MiddleCenter;
            GUI.skin.label.normal.textColor = addComp.editorPathColor;
            for (int i = 0; i < availablePoints.Length; i++)
            {
                if (addComp.isClosed && i == points.Length - 1)
                {
                    break;
                }

                Handles.Label(points[i].position + Camera.current.transform.up * HandleUtility.GetHandleSize(points[i].position) * 0.3f, (i + 1).ToString());
                if (SplineEditorHandles.CircleButton(points[availablePoints[i]].position, Quaternion.LookRotation(-camTransform.forward, camTransform.up), HandleUtility.GetHandleSize(points[availablePoints[i]].position) * 0.1f, 2f, addComp.editorPathColor))
                {
                    AddConnection(addComp, availablePoints[i]);
                    break;
                }
            }
            GUI.skin.label.alignment        = originalAlignment;
            GUI.skin.label.normal.textColor = originalColor;
        }
Пример #14
0
        public override void DrawScene()
        {
            editorCamera = SceneView.currentDrawingSceneView.camera;
            bool canCreate = false;

            if (placementMode == PlacementMode.CameraPlane)
            {
                GetCreatePointOnPlane(-editorCamera.transform.forward, editorCamera.transform.position + editorCamera.transform.forward * offset, out createPoint);
                Handles.color = new Color(1f, 0.78f, 0.12f);
                DrawGrid(createPoint, editorCamera.transform.forward, Vector2.one * 10, 2.5f);
                Handles.color = Color.white;
                canCreate     = true;
                createNormal  = -editorCamera.transform.forward;
            }

            if (placementMode == PlacementMode.Surface)
            {
                Ray        ray = HandleUtility.GUIPointToWorldRay(Event.current.mousePosition);
                RaycastHit hit;
                if (Physics.Raycast(ray, out hit, Mathf.Infinity, surfaceLayerMask))
                {
                    canCreate     = true;
                    createPoint   = hit.point + hit.normal * offset;
                    Handles.color = Color.blue;
                    Handles.DrawLine(hit.point, createPoint);
                    SplineEditorHandles.DrawRectangle(createPoint, Quaternion.LookRotation(-editorCamera.transform.forward, editorCamera.transform.up), HandleUtility.GetHandleSize(createPoint) * 0.1f);
                    Handles.color = Color.white;
                    createNormal  = hit.normal;
                }
            }

            if (placementMode == PlacementMode.XPlane)
            {
                canCreate    = AxisGrid(Vector3.right, new Color(0.85f, 0.24f, 0.11f, 0.92f), out createPoint);
                createNormal = Vector3.right;
            }

            if (placementMode == PlacementMode.YPlane)
            {
                canCreate    = AxisGrid(Vector3.up, new Color(0.6f, 0.95f, 0.28f, 0.92f), out createPoint);
                createNormal = Vector3.up;
            }

            if (placementMode == PlacementMode.ZPlane)
            {
                canCreate    = AxisGrid(Vector3.forward, new Color(0.22f, 0.47f, 0.97f, 0.92f), out createPoint);
                createNormal = Vector3.back;
            }

            if (placementMode == PlacementMode.Insert)
            {
                canCreate = true;
                if (points.Length < 2)
                {
                    placementMode = PlacementMode.YPlane;
                }
                else
                {
                    InsertMode(Event.current.mousePosition);
                }
            }
            else if (eventModule.mouseLeftDown && canCreate && !eventModule.mouseRight && !eventModule.alt)
            {
                CreateSplinePoint(createPoint, createNormal);
            }

            if (lastCreated >= 0 && lastCreated < points.Length && editor.eventModule.mouseLeft)
            {
                Vector3 tangent = points[lastCreated].position - createPoint;
                if (appendMode == AppendMode.End)
                {
                    tangent = createPoint - points[lastCreated].position;
                }
                points[lastCreated].SetTangent2Position(points[lastCreated].position + tangent);
            }
            else if (!editor.eventModule.mouseLeft)
            {
                lastCreated = -1;
            }


            if (!canCreate)
            {
                DrawMouseCross();
            }
            UpdateVisualizer();
            SplineDrawer.DrawSpline(visualizer, color);
            Repaint();
        }
Пример #15
0
        public override void DrawScene()
        {
            Transform camTransform = SceneView.currentDrawingSceneView.camera.transform;

            if (!drag)
            {
                if (finalize)
                {
                    if (rect.width > 0f && rect.height > 0f)
                    {
                        if (!eventModule.control)
                        {
                            ClearSelection();
                        }
                        for (int i = 0; i < points.Length; i++)
                        {
                            Vector2 guiPoint = HandleUtility.WorldToGUIPoint(points[i].position);
                            if (rect.Contains(guiPoint))
                            {
                                Vector3 local = camTransform.InverseTransformPoint(points[i].position);
                                if (local.z >= 0f)
                                {
                                    AddPointSelection(i);
                                }
                            }
                        }
                    }
                    finalize = false;
                }
            }
            else
            {
                rectEnd = Event.current.mousePosition;
                rect    = new Rect(Mathf.Min(rectStart.x, rectEnd.x), Mathf.Min(rectStart.y, rectEnd.y), Mathf.Abs(rectEnd.x - rectStart.x), Mathf.Abs(rectEnd.y - rectStart.y));
                if (rect.width >= minimumRectSize && rect.height >= minimumRectSize)
                {
                    Color col = SplinePrefs.highlightColor;
                    col.a = 0.4f;
                    Handles.BeginGUI();
                    EditorGUI.DrawRect(rect, col);
                    Handles.EndGUI();
                    SceneView.RepaintAll();
                }
            }
            TextAnchor originalAlignment = GUI.skin.label.alignment;
            Color      originalColor     = GUI.skin.label.normal.textColor;

            GUI.skin.label.alignment        = TextAnchor.MiddleCenter;
            GUI.skin.label.normal.textColor = color;

            for (int i = 0; i < points.Length; i++)
            {
                if (isClosed && i == points.Length - 1)
                {
                    break;
                }
                bool    moved      = false;
                bool    isSelected = selectedPoints.Contains(i);
                Vector3 lastPos    = points[i].position;
                Handles.color = Color.clear;
                if (SplinePrefs.showPointNumbers && camTransform.InverseTransformPoint(points[i].position).z > 0f)
                {
                    Handles.Label(points[i].position + Camera.current.transform.up * HandleUtility.GetHandleSize(points[i].position) * 0.3f, (i + 1).ToString());
                }
                if (excludeSelected && isSelected)
                {
                    SplineEditorHandles.FreeMoveRectangle(points[i].position, HandleUtility.GetHandleSize(points[i].position) * 0.1f);
                }
                else
                {
                    points[i].SetPosition(SplineEditorHandles.FreeMoveRectangle(points[i].position, HandleUtility.GetHandleSize(points[i].position) * 0.1f));
                }

                if (lastPos != points[i].position)
                {
                    RecordUndo("Move Points");
                    moved = true;
                    if (isSelected)
                    {
                        for (int n = 0; n < selectedPoints.Count; n++)
                        {
                            if (selectedPoints[n] == i)
                            {
                                continue;
                            }
                            points[selectedPoints[n]].SetPosition(points[selectedPoints[n]].position + (points[i].position - lastPos));
                        }
                    }
                    else
                    {
                        SelectPoint(i);
                    }
                    lastPos = points[i].position;
                }


                if (!moved && editor.eventModule.mouseLeftUp)
                {
                    if (SplineEditorHandles.HoverArea(points[i].position, 0.12f))
                    {
                        if (eventModule.shift)
                        {
                            ShiftSelect(i, points.Length);
                        }
                        else if (eventModule.control)
                        {
                            AddPointSelection(i);
                        }
                        else
                        {
                            SelectPoint(i);
                        }
                    }
                }
                if (!excludeSelected || !isSelected)
                {
                    Handles.color = color;
                    if (isSelected)
                    {
                        Handles.color = SplinePrefs.highlightColor;
                        Handles.DrawWireDisc(points[i].position, -SceneView.currentDrawingSceneView.camera.transform.forward, HandleUtility.GetHandleSize(points[i].position) * 0.14f);
                    }
                    else
                    {
                        Handles.color = color;
                    }
                    Handles.DrawSolidDisc(points[i].position, -SceneView.currentDrawingSceneView.camera.transform.forward, HandleUtility.GetHandleSize(points[i].position) * 0.09f);
                    Handles.color = Color.white;
                }
                moved = false;
            }
            GUI.skin.label.alignment        = originalAlignment;
            GUI.skin.label.normal.textColor = originalColor;

            if (splineType == Spline.Type.Bezier)
            {
                Handles.color = color;
                for (int i = 0; i < selectedPoints.Count; i++)
                {
                    Handles.DrawDottedLine(points[selectedPoints[i]].position, points[selectedPoints[i]].tangent, 4f);
                    Handles.DrawDottedLine(points[selectedPoints[i]].position, points[selectedPoints[i]].tangent2, 4f);
                    Vector3 lastPos = points[selectedPoints[i]].tangent;
                    Vector3 newPos  = SplineEditorHandles.FreeMoveCircle(points[selectedPoints[i]].tangent, HandleUtility.GetHandleSize(points[selectedPoints[i]].tangent) * 0.1f);
                    if (lastPos != newPos)
                    {
                        RecordUndo("Move Tangent");
                        points[selectedPoints[i]].SetTangentPosition(newPos);
                    }
                    lastPos = points[selectedPoints[i]].tangent2;
                    newPos  = SplineEditorHandles.FreeMoveCircle(points[selectedPoints[i]].tangent2, HandleUtility.GetHandleSize(points[selectedPoints[i]].tangent2) * 0.1f);
                    if (lastPos != newPos)
                    {
                        RecordUndo("Move Tangent");
                        points[selectedPoints[i]].SetTangent2Position(newPos);
                    }
                }
            }
            if (isDragging)
            {
                if (eventModule.alt || !SceneView.currentDrawingSceneView.camera.pixelRect.Contains(Event.current.mousePosition) || !eventModule.mouseLeft)
                {
                    FinishDrag();
                }
            }
        }
        public static bool Slider(SplineComputer spline, ref double percent, Color color, string text = "", SplineSliderGizmo gizmo = SplineSliderGizmo.Rectangle, float buttonSize = 1f)
        {
            Camera cam = SceneView.currentDrawingSceneView.camera;

            spline.Evaluate(percent, evalResult);
            float size = HandleUtility.GetHandleSize(evalResult.position);

            Handles.color = new Color(color.r, color.g, color.b, 0.4f);
            Handles.DrawSolidDisc(evalResult.position, cam.transform.position - evalResult.position, size * 0.2f * buttonSize);
            Handles.color = Color.white;
            if ((color.r + color.g + color.b + color.a) / 4f >= 0.9f)
            {
                Handles.color = Color.black;
            }

            Vector3 center         = evalResult.position;
            Vector2 screenPosition = HandleUtility.WorldToGUIPoint(center);

            screenPosition.y += 20f;
            Vector3 localPos = cam.transform.InverseTransformPoint(center);

            if (text != "" && localPos.z > 0f)
            {
                Handles.BeginGUI();
                DreamteckEditorGUI.Label(new Rect(screenPosition.x - 120 + text.Length * 4, screenPosition.y, 120, 25), text);
                Handles.EndGUI();
            }
            bool    buttonClick  = SplineEditorHandles.SliderButton(center, false, Color.white, 0.3f);
            Vector3 lookAtCamera = (cam.transform.position - evalResult.position).normalized;
            Vector3 right        = Vector3.Cross(lookAtCamera, evalResult.forward).normalized *size * 0.1f * buttonSize;
            Vector3 front        = Vector3.forward;

            switch (gizmo)
            {
            case SplineSliderGizmo.BackwardTriangle:
                center += evalResult.forward * size * 0.06f * buttonSize;
                front   = center - evalResult.forward * size * 0.2f * buttonSize;
                Handles.DrawLine(center + right, front);
                Handles.DrawLine(front, center - right);
                Handles.DrawLine(center - right, center + right);
                break;

            case SplineSliderGizmo.ForwardTriangle:
                center -= evalResult.forward * size * 0.06f * buttonSize;
                front   = center + evalResult.forward * size * 0.2f * buttonSize;
                Handles.DrawLine(center + right, front);
                Handles.DrawLine(front, center - right);
                Handles.DrawLine(center - right, center + right);
                break;

            case SplineSliderGizmo.DualArrow:
                center += evalResult.forward * size * 0.025f * buttonSize;
                front   = center + evalResult.forward * size * 0.17f * buttonSize;
                Handles.DrawLine(center + right, front);
                Handles.DrawLine(front, center - right);
                Handles.DrawLine(center - right, center + right);
                center -= evalResult.forward * size * 0.05f * buttonSize;
                front   = center - evalResult.forward * size * 0.17f * buttonSize;
                Handles.DrawLine(center + right, front);
                Handles.DrawLine(front, center - right);
                Handles.DrawLine(center - right, center + right);
                break;

            case SplineSliderGizmo.Rectangle:

                break;

            case SplineSliderGizmo.Circle:
                Handles.DrawWireDisc(center, lookAtCamera, 0.13f * size * buttonSize);
                break;
            }
            Vector3 lastPos = evalResult.position;

            Handles.color       = Color.clear;
            evalResult.position = Handles.FreeMoveHandle(evalResult.position, Quaternion.LookRotation(cam.transform.position - evalResult.position), size * 0.2f * buttonSize, Vector3.zero, Handles.CircleHandleCap);
            if (evalResult.position != lastPos)
            {
                percent = spline.Project(evalResult.position).percent;
            }
            Handles.color = Color.white;
            return(buttonClick);
        }