private static void AddCPathPoints() { if (SceneView.focusedWindow != null) { SceneView.focusedWindow.wantsMouseMove = true; } Handles.color = _cameraPath.selectedPointColour; CameraPathPointList pointList = null; switch (_pointMode) { case CameraPath.PointModes.AddOrientations: pointList = _cameraPath.orientationList; break; case CameraPath.PointModes.AddFovs: pointList = _cameraPath.fovList; break; case CameraPath.PointModes.AddTilts: pointList = _cameraPath.tiltList; break; case CameraPath.PointModes.AddEvents: pointList = _cameraPath.eventList; break; case CameraPath.PointModes.AddSpeeds: pointList = _cameraPath.speedList; break; case CameraPath.PointModes.AddDelays: pointList = _cameraPath.delayList; break; } int numberOfPoints = pointList.realNumberOfPoints; for (int i = 0; i < numberOfPoints; i++) { CameraPathPoint point = pointList[i]; float pointHandleSize = HandleUtility.GetHandleSize(point.worldPosition) * HANDLE_SCALE * 0.4f; Handles.DotCap(0, point.worldPosition, Quaternion.identity, pointHandleSize); } float mousePercentage = NearestmMousePercentage();// _track.GetNearestPoint(mousePlanePoint); Vector3 mouseTrackPoint = _cameraPath.GetPathPosition(mousePercentage, true); Handles.Label(mouseTrackPoint, "Add New Point"); float newPointHandleSize = HandleUtility.GetHandleSize(mouseTrackPoint) * HANDLE_SCALE; Ray mouseRay = Camera.current.ScreenPointToRay(new Vector3(Event.current.mousePosition.x, Screen.height - Event.current.mousePosition.y - 30, 0)); Quaternion mouseLookDirection = Quaternion.LookRotation(-mouseRay.direction); if (Handles.Button(mouseTrackPoint, mouseLookDirection, newPointHandleSize, newPointHandleSize, Handles.DotCap)) { CameraPathControlPoint curvePointA = _cameraPath[_cameraPath.GetLastPointIndex(mousePercentage, false)]; CameraPathControlPoint curvePointB = _cameraPath[_cameraPath.GetNextPointIndex(mousePercentage, false)]; float curvePercentage = _cameraPath.GetCurvePercentage(curvePointA, curvePointB, mousePercentage); switch (_pointMode) { case CameraPath.PointModes.AddOrientations: Quaternion pointRotation = Quaternion.LookRotation(_cameraPath.GetPathDirection(mousePercentage)); CameraPathOrientation newOrientation = ((CameraPathOrientationList)pointList).AddOrientation(curvePointA, curvePointB, curvePercentage, pointRotation); ChangeSelectedPointIndex(pointList.IndexOf(newOrientation)); break; case CameraPath.PointModes.AddFovs: float pointFOV = _cameraPath.fovList.GetValue(mousePercentage, CameraPathFOVList.ProjectionType.FOV); float pointSize = _cameraPath.fovList.GetValue(mousePercentage, CameraPathFOVList.ProjectionType.Orthographic); CameraPathFOV newFOVPoint = ((CameraPathFOVList)pointList).AddFOV(curvePointA, curvePointB, curvePercentage, pointFOV, pointSize); ChangeSelectedPointIndex(pointList.IndexOf(newFOVPoint)); break; case CameraPath.PointModes.AddTilts: float pointTilt = _cameraPath.GetPathTilt(mousePercentage); CameraPathTilt newTiltPoint = ((CameraPathTiltList)pointList).AddTilt(curvePointA, curvePointB, curvePercentage, pointTilt); ChangeSelectedPointIndex(pointList.IndexOf(newTiltPoint)); break; case CameraPath.PointModes.AddEvents: CameraPathEvent newEventPoint = ((CameraPathEventList)pointList).AddEvent(curvePointA, curvePointB, curvePercentage); ChangeSelectedPointIndex(pointList.IndexOf(newEventPoint)); break; case CameraPath.PointModes.AddSpeeds: _cameraPath.speedList.listEnabled = true; //if we're adding speeds then we probable want to enable it CameraPathSpeed newSpeedPoint = ((CameraPathSpeedList)pointList).AddSpeedPoint(curvePointA, curvePointB, curvePercentage); newSpeedPoint.speed = _animator.pathSpeed; ChangeSelectedPointIndex(pointList.IndexOf(newSpeedPoint)); break; case CameraPath.PointModes.AddDelays: CameraPathDelay newDelayPoint = ((CameraPathDelayList)pointList).AddDelayPoint(curvePointA, curvePointB, curvePercentage); ChangeSelectedPointIndex(pointList.IndexOf(newDelayPoint)); break; } GUI.changed = true; } }