private static void RemoveCPathPoints() { if (SceneView.focusedWindow != null) { SceneView.focusedWindow.wantsMouseMove = true; } CameraPathPointList pointList = null; switch (_pointMode) { case CameraPath.PointModes.RemoveOrientations: pointList = _cameraPath.orientationList; break; case CameraPath.PointModes.RemoveFovs: pointList = _cameraPath.fovList; break; case CameraPath.PointModes.RemoveTilts: pointList = _cameraPath.tiltList; break; case CameraPath.PointModes.RemoveEvents: pointList = _cameraPath.eventList; break; case CameraPath.PointModes.RemoveSpeeds: pointList = _cameraPath.speedList; break; case CameraPath.PointModes.RemoveDelays: pointList = _cameraPath.delayList; break; } int numberOfPoints = pointList.realNumberOfPoints; Handles.color = _cameraPath.selectedPointColour; Quaternion mouseLookDirection = Quaternion.LookRotation(Camera.current.transform.forward); for (int i = 0; i < numberOfPoints; i++) { CameraPathPoint point = pointList[i]; float pointHandleSize = HandleUtility.GetHandleSize(point.worldPosition) * HANDLE_SCALE; Handles.Label(point.worldPosition, "Remove Point " + i); if (Handles.Button(point.worldPosition, mouseLookDirection, pointHandleSize, pointHandleSize, Handles.DotCap)) { pointList.RemovePoint(point); GUI.changed = true; return; } } }
public CameraPathPoint GetPoint(int index) { int numberOfPoints = _points.Count; if (numberOfPoints == 0) { return(null); } CameraPathPointList list = this; if (cameraPath.shouldInterpolateNextPath) { switch (pointTypeName) { case "Orientation": list = cameraPath.nextPath.orientationList; break; case "FOV": list = cameraPath.nextPath.fovList; break; case "Tilt": list = cameraPath.nextPath.tiltList; break; } } if (list == this)//we're not interpolating next paths { if (!cameraPath.loop) { return(_points[Mathf.Clamp(index, 0, numberOfPoints - 1)]); } if (index >= numberOfPoints) { index = index - numberOfPoints; } if (index < 0) { index = index + numberOfPoints; } } else { if (cameraPath.loop) { if (index == numberOfPoints) { index = 0; list = null;//not using next path } else if (index > numberOfPoints) { index = Mathf.Clamp(index, 0, list.realNumberOfPoints - 1); } else if (index < 0) { index = index + numberOfPoints; list = null;//not using next path } else { list = null;//not using next path } } else { if (index > numberOfPoints - 1) { index = Mathf.Clamp(index - numberOfPoints, 0, list.realNumberOfPoints - 1); } else if (index < 0) { index = 0; list = null;//not using next path } else { index = Mathf.Clamp(index, 0, numberOfPoints - 1); list = null;//not using next path } } } if (list != null) { return(list[index]); } else { return(_points[index]); } }
private static void CPPointArrayInspector(string title, CameraPathPointList pointList, CameraPath.PointModes deflt, CameraPath.PointModes add, CameraPath.PointModes remove) { EditorGUILayout.Space(); EditorGUILayout.LabelField(title); int numberOfPoints = pointList.realNumberOfPoints; if (numberOfPoints == 0) EditorGUILayout.LabelField("There are no points", redText); CameraPathPoint duplicatePoint = pointList.DuplicatePointCheck(); if (duplicatePoint != null) EditorGUILayout.HelpBox("There are points occuping the same percentage.\n Check " + duplicatePoint.displayName + " thanks.", MessageType.Error); for (int i = 0; i < numberOfPoints; i++) { bool cantDelete = false; bool pointIsSelected = i == selectedPointIndex; EditorGUILayout.BeginHorizontal((pointIsSelected) ? selectedBox : unselectedBox); CameraPathPoint arrayPoint = pointList[i]; EditorGUILayout.BeginHorizontal(); if (arrayPoint.customName == "") EditorGUILayout.LabelField("Point " + i, GUILayout.Width(100)); else EditorGUILayout.LabelField(arrayPoint.customName, GUILayout.Width(100)); float valueTextSize = 120; switch (deflt) { case CameraPath.PointModes.FOV: CameraPathFOV fov = (CameraPathFOV)arrayPoint; fov.FOV = EditorGUILayout.FloatField(fov.FOV, GUILayout.Width(50)); break; case CameraPath.PointModes.Speed: CameraPathSpeed speed = (CameraPathSpeed)arrayPoint; speed.speed = EditorGUILayout.FloatField(speed.speed, GUILayout.Width(50)); break; case CameraPath.PointModes.Delay: CameraPathDelay delay = (CameraPathDelay)arrayPoint; if (delay != _cameraPath.delayList.outroPoint) { delay.time = EditorGUILayout.FloatField(delay.time, GUILayout.Width(50)); EditorGUILayout.LabelField("secs", GUILayout.Width(40)); if (delay != _cameraPath.delayList.introPoint) cantDelete = false; else cantDelete = true; } else { cantDelete = true; } break; case CameraPath.PointModes.Ease: cantDelete = true; break; case CameraPath.PointModes.Orientations: CameraPathOrientation orientation = (CameraPathOrientation)arrayPoint; EditorGUILayout.LabelField(orientation.rotation.eulerAngles.ToString(), GUILayout.Width(valueTextSize)); break; case CameraPath.PointModes.Tilt: CameraPathTilt tilt = (CameraPathTilt)arrayPoint; tilt.tilt = EditorGUILayout.FloatField(tilt.tilt, GUILayout.Width(50)); break; case CameraPath.PointModes.Events: CameraPathEvent point = (CameraPathEvent)arrayPoint; point.type = (CameraPathEvent.Types)EditorGUILayout.EnumPopup(point.type, GUILayout.Width(50)); if (point.type == CameraPathEvent.Types.Broadcast) point.eventName = EditorGUILayout.TextField(point.eventName, GUILayout.Width(120)); else { point.target = (GameObject)EditorGUILayout.ObjectField(point.target, typeof(GameObject), true); point.methodName = EditorGUILayout.TextField(point.methodName, GUILayout.Width(55)); } break; } if (!pointIsSelected) { if (GUILayout.Button("Select", GUILayout.Width(60))) { ChangeSelectedPointIndex(i); GotoScenePoint(arrayPoint.worldPosition); } } else { if (GUILayout.Button("Go to", GUILayout.Width(60))) { GotoScenePoint(arrayPoint.worldPosition); } } if (!cantDelete) { if (GUILayout.Button("Delete", GUILayout.Width(60))) { pointList.RemovePoint(arrayPoint); return; } } EditorGUILayout.EndHorizontal(); EditorGUILayout.EndHorizontal(); } if (deflt == CameraPath.PointModes.Ease || deflt == CameraPath.PointModes.ControlPoints) return; //ADD NEW POINTS EditorGUILayout.BeginVertical("box"); EditorGUI.BeginDisabledGroup(_pointMode != deflt); if (GUILayout.Button("Add Point From Inspector")) AddCPointAtPercent(_cameraPath.addPointAtPercent); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("At Percent", GUILayout.Width(80)); _cameraPath.addPointAtPercent = EditorGUILayout.Slider(_cameraPath.addPointAtPercent, 0, 1); EditorGUILayout.EndHorizontal(); EditorGUI.EndDisabledGroup(); EditorGUILayout.EndVertical(); if (_pointMode != add) { if (GUILayout.Button("Add Points in Scene")) { ChangePointMode(add); } } else { if (GUILayout.Button("Done Adding Points")) { ChangePointMode(deflt); } } EditorGUI.BeginDisabledGroup(numberOfPoints == 0); if (_pointMode != remove) { if (GUILayout.Button("Delete Points in Scene")) { ChangePointMode(remove); } } else { if (GUILayout.Button("Done")) { ChangePointMode(deflt); } } EditorGUI.EndDisabledGroup(); }
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; } }
public CameraPathPoint GetPoint(int index) { int count = this._points.get_Count(); if (count == 0) { return(null); } CameraPathPointList cameraPathPointList = this; if (this.cameraPath.shouldInterpolateNextPath) { string text = this.pointTypeName; if (text != null) { if (CameraPathPointList.< > f__switch$map11 == null) { Dictionary <string, int> dictionary = new Dictionary <string, int>(3); dictionary.Add("Orientation", 0); dictionary.Add("FOV", 1); dictionary.Add("Tilt", 2); CameraPathPointList.< > f__switch$map11 = dictionary; } int num; if (CameraPathPointList.< > f__switch$map11.TryGetValue(text, ref num)) { switch (num) { case 0: cameraPathPointList = this.cameraPath.nextPath.orientationList; break; case 1: cameraPathPointList = this.cameraPath.nextPath.fovList; break; case 2: cameraPathPointList = this.cameraPath.nextPath.tiltList; break; } } } } if (cameraPathPointList == this) { if (!this.cameraPath.loop) { return(this._points.get_Item(Mathf.Clamp(index, 0, count - 1))); } if (index >= count) { index -= count; } if (index < 0) { index += count; } } else if (this.cameraPath.loop) { if (index == count) { index = 0; cameraPathPointList = null; } else if (index > count) { index = Mathf.Clamp(index, 0, cameraPathPointList.realNumberOfPoints - 1); } else if (index < 0) { index += count; cameraPathPointList = null; } else { cameraPathPointList = null; } } else if (index > count - 1) { index = Mathf.Clamp(index - count, 0, cameraPathPointList.realNumberOfPoints - 1); } else if (index < 0) { index = 0; cameraPathPointList = null; } else { index = Mathf.Clamp(index, 0, count - 1); cameraPathPointList = null; } if (cameraPathPointList != null) { return(cameraPathPointList[index]); } return(this._points.get_Item(index)); }