/// <summary> /// Adds a new control point to the scene view and its drag point data /// to the game object. /// </summary> public void AddDragPointOnTraveller() { if (CurveTravellerControlPointIdx < 0 || CurveTravellerControlPointIdx >= ControlPoints.Count) { return; } var dragPoint = new DragPointData(DragPointEditable.GetDragPoints()[CurveTravellerControlPointIdx]) { IsLocked = false }; var newIdx = CurveTravellerControlPointIdx + 1; float ratio = (float)newIdx / (DragPointEditable.GetDragPoints().Length - 1); var dragPointPosition = Transform.worldToLocalMatrix.MultiplyPoint(CurveTravellerPosition); dragPointPosition -= DragPointEditable.GetEditableOffset(); dragPointPosition -= DragPointEditable.GetDragPointOffset(ratio); dragPoint.Vertex = dragPointPosition.ToVertex3D(); var dragPoints = DragPointEditable.GetDragPoints().ToList(); dragPoints.Insert(newIdx, dragPoint); DragPointEditable.SetDragPoints(dragPoints.ToArray()); ControlPoints.Insert(newIdx, new ControlPoint( DragPointEditable.GetDragPoints()[newIdx], GUIUtility.GetControlID(FocusType.Passive), newIdx, ratio )); RebuildControlPoints(); }