Repository: FlaxEngine/FlaxEngine
File: Source/Editor/SceneGraph/Actors/SplineNode.cs (C#)

Code before:

                base.OnDispose();
            }
        }

        private const Real PointNodeSize = 1.5f;
        private const Real TangentNodeSize = 1.0f;
        private const Real SnapIndicatorSize = 1.7f;
        private const Real SnapPointIndicatorSize = 2f;

        private static Spline _currentEditSpline;

        /// <inheritdoc />
        public SplineNode(Actor actor)
        : base(actor)
        {
            OnUpdate();
            FlaxEngine.Scripting.Update += OnUpdate;
        }

        private unsafe void OnUpdate()
        {
            if (Input.Keyboard.GetKey(KeyboardKeys.Shift))
            {
                EditSplineWithSnap();
            }

            // Sync spline points with gizmo handles
            var actor = (Spline)Actor;
            var dstCount = actor.SplinePointsCount;
            if (dstCount > 1 && actor.IsLoop)
                dstCount--; // The last point is the same as the first one for loop mode
            var srcCount = ActorChildNodes?.Count ?? 0;
            if (dstCount != srcCount)
            {
                // Remove unused points
                while (srcCount > dstCount)
                {
                    var node = ActorChildNodes[srcCount-- - 1];
                    // TODO: support selection interface inside SceneGraph nodes (eg. on Root) so prefab editor can handle this too
                    if (Editor.Instance.SceneEditing.Selection.Contains(node))
                        Editor.Instance.SceneEditing.Deselect();
                    node.Dispose();
                }

                // Add new points
                var id = ID;
                var g = (JsonSerializer.GuidInterop*)&id;
                g->D += (uint)srcCount * 3;
                while (srcCount < dstCount)
                {

Review comment (refactor):
I have used Shift, this can be changed in the future.

I tried using Control but this comflicts with TransformGizmo snap, using Shift has a small problem, if you press Shift before start move selected spline point has ben duplicated (Duplicate point shortcut is shift key too....)

Code after:
            public override void OnDispose()
            {
                _node = null;

                base.OnDispose();
            }
        }

        private const Real PointNodeSize = 1.5f;
        private const Real TangentNodeSize = 1.0f;
        private const Real SnapIndicatorSize = 1.7f;
        private const Real SnapPointIndicatorSize = 2f;

        private static Spline _currentEditSpline;

        /// <inheritdoc />
        public SplineNode(Actor actor)
        : base(actor)
        {
            OnUpdate();
            FlaxEngine.Scripting.Update += OnUpdate;
        }

        private void OnUpdate()
        {
            if (Input.Keyboard.GetKey(KeyboardKeys.Shift))
            {
                EditSplineWithSnap();
            }

            var canAddSplinePoint = Input.Mouse.PositionDelta == Float2.Zero && Input.Mouse.Position != Float2.Zero;
            var requestAddSplinePoint = Input.Keyboard.GetKey(KeyboardKeys.Control) && Input.Mouse.GetButtonDown(MouseButton.Right);

            if (requestAddSplinePoint && canAddSplinePoint)
                AddSplinePoint();

            SyncSplineKeyframeWithNodes();
        }

        private unsafe void SyncSplineKeyframeWithNodes()
        {
            var actor = (Spline)Actor;
            var dstCount = actor.SplinePointsCount;
            if (dstCount > 1 && actor.IsLoop)
                dstCount--; // The last point is the same as the first one for loop mode
            var srcCount = ActorChildNodes?.Count ?? 0;
            if (dstCount != srcCount)
            {
                // Remove unused points
                while (srcCount > dstCount)
                {