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); } } }
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); } }