private void ResetDragging() { if (this.m_DraggingCurveOrRegion != null) { this.selectedCurves = this.preCurveDragSelection; this.preCurveDragSelection = (List<CurveSelection>) null; } GUIUtility.hotControl = 0; this.m_DraggingKey = (CurveWrapper) null; this.m_DraggingCurveOrRegion = (CurveWrapper[]) null; this.m_MoveCoord = Vector2.zero; this.m_AxisLock = CurveEditor.AxisLock.None; }
public Vector2 MovePoints() { int controlId = GUIUtility.GetControlID(FocusType.Passive); if (!this.hasSelection && !this.settings.allowDraggingCurvesAndRegions) return Vector2.zero; Event current1 = Event.current; switch (current1.GetTypeForControl(controlId)) { case EventType.MouseDown: if (current1.button == 0) { using (List<CurveSelection>.Enumerator enumerator = this.selectedCurves.GetEnumerator()) { while (enumerator.MoveNext()) { CurveSelection current2 = enumerator.Current; if (!current2.curveWrapper.hidden && (double) (this.DrawingToViewTransformPoint(this.GetPosition(current2)) - current1.mousePosition).sqrMagnitude <= 100.0) { this.SetupKeyOrCurveDragging(new Vector2(current2.keyframe.time, current2.keyframe.value), current2.curveWrapper, controlId, current1.mousePosition); break; } } } if (this.settings.allowDraggingCurvesAndRegions && this.m_DraggingKey == null) { Vector2 zero = Vector2.zero; CurveWrapper[] curves = (CurveWrapper[]) null; if (this.HandleCurveAndRegionMoveToFrontOnMouseDown(ref zero, ref curves)) { List<CurveSelection> curveSelectionList = new List<CurveSelection>(); foreach (CurveWrapper curveWrapper in curves) { for (int keyIndex = 0; keyIndex < curveWrapper.curve.keys.Length; ++keyIndex) curveSelectionList.Add(new CurveSelection(curveWrapper.id, this, keyIndex)); this.MoveCurveToFront(curveWrapper.id); } this.preCurveDragSelection = this.selectedCurves; this.selectedCurves = curveSelectionList; this.SetupKeyOrCurveDragging(zero, curves[0], controlId, current1.mousePosition); this.m_DraggingCurveOrRegion = curves; break; } break; } break; } break; case EventType.MouseUp: if (GUIUtility.hotControl == controlId) { this.ResetDragging(); GUI.changed = true; current1.Use(); break; } break; case EventType.MouseDrag: if (GUIUtility.hotControl == controlId) { Vector2 lhs = current1.mousePosition - this.s_StartMouseDragPosition; Vector3 vector3 = Vector3.zero; if (current1.shift && this.m_AxisLock == CurveEditor.AxisLock.None) this.m_AxisLock = (double) Mathf.Abs(lhs.x) <= (double) Mathf.Abs(lhs.y) ? CurveEditor.AxisLock.Y : CurveEditor.AxisLock.X; if (this.m_DraggingCurveOrRegion != null) { lhs.x = 0.0f; vector3 = (Vector3) this.ViewToDrawingTransformVector(lhs); vector3.y = this.SnapValue(vector3.y + this.s_StartKeyDragPosition.y) - this.s_StartKeyDragPosition.y; } else { switch (this.m_AxisLock) { case CurveEditor.AxisLock.None: vector3 = (Vector3) this.ViewToDrawingTransformVector(lhs); vector3.x = this.SnapTime(vector3.x + this.s_StartKeyDragPosition.x) - this.s_StartKeyDragPosition.x; vector3.y = this.SnapValue(vector3.y + this.s_StartKeyDragPosition.y) - this.s_StartKeyDragPosition.y; break; case CurveEditor.AxisLock.X: lhs.y = 0.0f; vector3 = (Vector3) this.ViewToDrawingTransformVector(lhs); vector3.x = this.SnapTime(vector3.x + this.s_StartKeyDragPosition.x) - this.s_StartKeyDragPosition.x; break; case CurveEditor.AxisLock.Y: lhs.x = 0.0f; vector3 = (Vector3) this.ViewToDrawingTransformVector(lhs); vector3.y = this.SnapValue(vector3.y + this.s_StartKeyDragPosition.y) - this.s_StartKeyDragPosition.y; break; } } this.TranslateSelectedKeys((Vector2) vector3); GUI.changed = true; current1.Use(); return (Vector2) vector3; } break; case EventType.KeyDown: if (GUIUtility.hotControl == controlId && current1.keyCode == KeyCode.Escape) { this.TranslateSelectedKeys(Vector2.zero); this.ResetDragging(); GUI.changed = true; current1.Use(); break; } break; case EventType.Repaint: if (this.m_DraggingCurveOrRegion != null) { EditorGUIUtility.AddCursorRect(new Rect(current1.mousePosition.x - 10f, current1.mousePosition.y - 10f, 20f, 20f), MouseCursor.ResizeVertical); break; } break; } return Vector2.zero; }