コード例 #1
0
		private void SelectPoints()
		{
			int controlID = GUIUtility.GetControlID(897560, FocusType.Passive);
			Event current = Event.current;
			bool shift = current.shift;
			EventType typeForControl = current.GetTypeForControl(controlID);
			switch (typeForControl)
			{
			case EventType.MouseDown:
				if (current.clickCount == 2 && current.button == 0)
				{
					this.CreateKeyFromClick(base.mousePositionInDrawing);
				}
				else
				{
					if (current.button == 0)
					{
						CurveSelection curveSelection = this.FindNearest();
						if (curveSelection == null || curveSelection.semiSelected)
						{
							if (!shift)
							{
								this.SelectNone();
							}
							Vector2 zero = Vector2.zero;
							CurveWrapper[] array = null;
							this.HandleCurveAndRegionMoveToFrontOnMouseDown(ref zero, ref array);
							GUIUtility.hotControl = controlID;
							this.s_EndMouseDragPosition = (this.s_StartMouseDragPosition = current.mousePosition);
							this.s_PickMode = CurveEditor.PickMode.Click;
						}
						else
						{
							this.MoveCurveToFront(curveSelection.curveID);
							this.activeTime = curveSelection.keyframe.time;
							this.s_StartKeyDragPosition = new Vector2(curveSelection.keyframe.time, curveSelection.keyframe.value);
							if (shift)
							{
								List<CurveSelection> list = new List<CurveSelection>(this.m_Selection);
								if (this.m_Selection.IndexOf(curveSelection) == -1)
								{
									list.Add(curveSelection);
									list.Sort();
								}
								this.m_Selection = list;
							}
							else
							{
								if (this.m_Selection.IndexOf(curveSelection) == -1)
								{
									this.m_Selection = new List<CurveSelection>(1);
									this.m_Selection.Add(curveSelection);
								}
							}
						}
						GUI.changed = true;
						HandleUtility.Repaint();
					}
				}
				goto IL_3E3;
			case EventType.MouseUp:
				if (GUIUtility.hotControl == controlID)
				{
					GUIUtility.hotControl = 0;
					this.s_PickMode = CurveEditor.PickMode.None;
					Event.current.Use();
				}
				goto IL_3E3;
			case EventType.MouseMove:
			{
				IL_39:
				if (typeForControl == EventType.Layout)
				{
					HandleUtility.AddDefaultControl(controlID);
					goto IL_3E3;
				}
				if (typeForControl != EventType.ContextClick)
				{
					goto IL_3E3;
				}
				Rect drawRect = base.drawRect;
				float num = 0f;
				drawRect.y = num;
				drawRect.x = num;
				if (drawRect.Contains(Event.current.mousePosition))
				{
					Vector2 vector;
					int curveAtPosition = this.GetCurveAtPosition(base.mousePositionInDrawing, out vector);
					if (curveAtPosition >= 0)
					{
						GenericMenu genericMenu = new GenericMenu();
						genericMenu.AddItem(new GUIContent("Add Key"), false, new GenericMenu.MenuFunction2(this.CreateKeyFromClick), base.mousePositionInDrawing);
						genericMenu.ShowAsContext();
						Event.current.Use();
					}
				}
				goto IL_3E3;
			}
			case EventType.MouseDrag:
				if (GUIUtility.hotControl == controlID)
				{
					this.s_EndMouseDragPosition = current.mousePosition;
					if (this.s_PickMode == CurveEditor.PickMode.Click)
					{
						this.s_PickMode = CurveEditor.PickMode.Marquee;
						if (shift)
						{
							this.s_SelectionBackup = new List<CurveSelection>(this.m_Selection);
						}
						else
						{
							this.s_SelectionBackup = new List<CurveSelection>();
						}
					}
					else
					{
						Rect rect = EditorGUIExt.FromToRect(this.s_StartMouseDragPosition, current.mousePosition);
						List<CurveSelection> list2 = new List<CurveSelection>(this.s_SelectionBackup);
						CurveWrapper[] animationCurves = this.m_AnimationCurves;
						for (int i = 0; i < animationCurves.Length; i++)
						{
							CurveWrapper curveWrapper = animationCurves[i];
							if (!curveWrapper.readOnly && !curveWrapper.hidden)
							{
								int num2 = 0;
								Keyframe[] keys = curveWrapper.curve.keys;
								for (int j = 0; j < keys.Length; j++)
								{
									Keyframe keyframe = keys[j];
									if (rect.Contains(this.GetGUIPoint(new Vector2(keyframe.time, keyframe.value))))
									{
										list2.Add(new CurveSelection(curveWrapper.id, this, num2));
										this.MoveCurveToFront(curveWrapper.id);
									}
									num2++;
								}
							}
						}
						list2.Sort();
						this.m_Selection = list2;
						GUI.changed = true;
					}
					current.Use();
				}
				goto IL_3E3;
			}
			goto IL_39;
			IL_3E3:
			if (this.s_PickMode == CurveEditor.PickMode.Marquee)
			{
				GUI.Label(EditorGUIExt.FromToRect(this.s_StartMouseDragPosition, this.s_EndMouseDragPosition), GUIContent.none, this.ms_Styles.selectionRect);
			}
		}
コード例 #2
0
 private void SelectPoints()
 {
   int controlId = GUIUtility.GetControlID(897560, FocusType.Passive);
   Event current = Event.current;
   bool shift = current.shift;
   bool actionKey = EditorGUI.actionKey;
   EventType typeForControl = current.GetTypeForControl(controlId);
   switch (typeForControl)
   {
     case EventType.MouseDown:
       if (current.clickCount == 2 && current.button == 0)
       {
         // ISSUE: object of a compiler-generated type is created
         // ISSUE: variable of a compiler-generated type
         CurveEditor.\u003CSelectPoints\u003Ec__AnonStorey46 pointsCAnonStorey46 = new CurveEditor.\u003CSelectPoints\u003Ec__AnonStorey46();
         // ISSUE: reference to a compiler-generated field
         pointsCAnonStorey46.selectedPoint = this.FindNearest();
         // ISSUE: reference to a compiler-generated field
         if (pointsCAnonStorey46.selectedPoint != null)
         {
           if (!shift)
             this.ClearSelection();
           // ISSUE: object of a compiler-generated type is created
           // ISSUE: variable of a compiler-generated type
           CurveEditor.\u003CSelectPoints\u003Ec__AnonStorey47 pointsCAnonStorey47 = new CurveEditor.\u003CSelectPoints\u003Ec__AnonStorey47();
           // ISSUE: reference to a compiler-generated field
           pointsCAnonStorey47.\u003C\u003Ef__ref\u002470 = pointsCAnonStorey46;
           // ISSUE: reference to a compiler-generated field
           // ISSUE: reference to a compiler-generated field
           // ISSUE: reference to a compiler-generated field
           // ISSUE: reference to a compiler-generated field
           // ISSUE: reference to a compiler-generated field
           for (pointsCAnonStorey47.keyIndex = 0; pointsCAnonStorey47.keyIndex < pointsCAnonStorey46.selectedPoint.curve.keys.Length; pointsCAnonStorey47.keyIndex = pointsCAnonStorey47.keyIndex + 1)
           {
             // ISSUE: reference to a compiler-generated method
             if (!this.selectedCurves.Any<CurveSelection>(new Func<CurveSelection, bool>(pointsCAnonStorey47.\u003C\u003Em__77)))
             {
               // ISSUE: reference to a compiler-generated field
               // ISSUE: reference to a compiler-generated field
               this.AddSelection(new CurveSelection(pointsCAnonStorey46.selectedPoint.curveID, this, pointsCAnonStorey47.keyIndex));
             }
           }
         }
         else
           this.CreateKeyFromClick(this.mousePositionInDrawing);
         current.Use();
         break;
       }
       if (current.button == 0)
       {
         CurveSelection nearest = this.FindNearest();
         if (nearest == null || nearest.semiSelected)
         {
           Vector2 zero = Vector2.zero;
           CurveWrapper[] curves = (CurveWrapper[]) null;
           bool frontOnMouseDown = this.HandleCurveAndRegionMoveToFrontOnMouseDown(ref zero, ref curves);
           if (!shift && !actionKey && !frontOnMouseDown)
             this.SelectNone();
           GUIUtility.hotControl = controlId;
           this.s_EndMouseDragPosition = this.s_StartMouseDragPosition = current.mousePosition;
           this.s_PickMode = CurveEditor.PickMode.Click;
         }
         else
         {
           this.MoveCurveToFront(nearest.curveID);
           this.activeTime = nearest.keyframe.time;
           this.s_StartKeyDragPosition = new Vector2(nearest.keyframe.time, nearest.keyframe.value);
           if (shift)
           {
             if (this.lastSelected == null || nearest.curveID != this.lastSelected.curveID)
             {
               if (!this.selectedCurves.Contains(nearest))
                 this.AddSelection(nearest);
             }
             else
             {
               // ISSUE: object of a compiler-generated type is created
               // ISSUE: variable of a compiler-generated type
               CurveEditor.\u003CSelectPoints\u003Ec__AnonStorey48 pointsCAnonStorey48 = new CurveEditor.\u003CSelectPoints\u003Ec__AnonStorey48();
               // ISSUE: reference to a compiler-generated field
               pointsCAnonStorey48.rangeCurveID = nearest.curveID;
               int num1 = Mathf.Min(this.lastSelected.key, nearest.key);
               int num2 = Mathf.Max(this.lastSelected.key, nearest.key);
               // ISSUE: object of a compiler-generated type is created
               // ISSUE: variable of a compiler-generated type
               CurveEditor.\u003CSelectPoints\u003Ec__AnonStorey49 pointsCAnonStorey49 = new CurveEditor.\u003CSelectPoints\u003Ec__AnonStorey49();
               // ISSUE: reference to a compiler-generated field
               pointsCAnonStorey49.\u003C\u003Ef__ref\u002472 = pointsCAnonStorey48;
               // ISSUE: reference to a compiler-generated field
               // ISSUE: reference to a compiler-generated field
               // ISSUE: reference to a compiler-generated field
               // ISSUE: reference to a compiler-generated field
               for (pointsCAnonStorey49.keyIndex = num1; pointsCAnonStorey49.keyIndex <= num2; pointsCAnonStorey49.keyIndex = pointsCAnonStorey49.keyIndex + 1)
               {
                 // ISSUE: reference to a compiler-generated method
                 if (!this.selectedCurves.Any<CurveSelection>(new Func<CurveSelection, bool>(pointsCAnonStorey49.\u003C\u003Em__78)))
                 {
                   // ISSUE: reference to a compiler-generated field
                   // ISSUE: reference to a compiler-generated field
                   this.AddSelection(new CurveSelection(pointsCAnonStorey48.rangeCurveID, this, pointsCAnonStorey49.keyIndex));
                 }
               }
             }
             Event.current.Use();
           }
           else if (actionKey)
           {
             if (!this.selectedCurves.Contains(nearest))
               this.AddSelection(nearest);
             else
               this.RemoveSelection(nearest);
             Event.current.Use();
           }
           else if (!this.selectedCurves.Contains(nearest))
           {
             this.ClearSelection();
             this.AddSelection(nearest);
           }
         }
         GUI.changed = true;
         HandleUtility.Repaint();
         break;
       }
       break;
     case EventType.MouseUp:
       if (GUIUtility.hotControl == controlId)
       {
         GUIUtility.hotControl = 0;
         this.s_PickMode = CurveEditor.PickMode.None;
         Event.current.Use();
         break;
       }
       break;
     case EventType.MouseDrag:
       if (GUIUtility.hotControl == controlId)
       {
         this.s_EndMouseDragPosition = current.mousePosition;
         if (this.s_PickMode == CurveEditor.PickMode.Click)
         {
           this.s_PickMode = CurveEditor.PickMode.Marquee;
           this.s_SelectionBackup = !shift ? new List<CurveSelection>() : new List<CurveSelection>((IEnumerable<CurveSelection>) this.selectedCurves);
         }
         else
         {
           Rect rect = EditorGUIExt.FromToRect(this.s_StartMouseDragPosition, current.mousePosition);
           List<CurveSelection> curveSelectionList = new List<CurveSelection>((IEnumerable<CurveSelection>) this.s_SelectionBackup);
           foreach (CurveWrapper animationCurve in this.m_AnimationCurves)
           {
             if (!animationCurve.readOnly && !animationCurve.hidden)
             {
               int keyIndex = 0;
               foreach (Keyframe key in animationCurve.curve.keys)
               {
                 if (rect.Contains(this.GetGUIPoint((Vector3) new Vector2(key.time, key.value))))
                 {
                   curveSelectionList.Add(new CurveSelection(animationCurve.id, this, keyIndex));
                   this.MoveCurveToFront(animationCurve.id);
                 }
                 ++keyIndex;
               }
             }
           }
           this.selectedCurves = curveSelectionList;
           GUI.changed = true;
         }
         current.Use();
         break;
       }
       break;
     default:
       if (typeForControl != EventType.Layout)
       {
         if (typeForControl == EventType.ContextClick)
         {
           Rect drawRect = this.drawRect;
           // ISSUE: explicit reference operation
           // ISSUE: variable of a reference type
           Rect& local = @drawRect;
           float num1 = 0.0f;
           drawRect.y = num1;
           double num2 = (double) num1;
           // ISSUE: explicit reference operation
           (^local).x = (float) num2;
           Vector2 closestPointOnCurve;
           if (drawRect.Contains(Event.current.mousePosition) && this.GetCurveAtPosition(this.mousePositionInDrawing, out closestPointOnCurve) >= 0)
           {
             GenericMenu genericMenu = new GenericMenu();
             genericMenu.AddItem(new GUIContent("Add Key"), false, new GenericMenu.MenuFunction2(this.CreateKeyFromClick), (object) this.mousePositionInDrawing);
             genericMenu.ShowAsContext();
             Event.current.Use();
             break;
           }
           break;
         }
         break;
       }
       HandleUtility.AddDefaultControl(controlId);
       break;
   }
   if (this.s_PickMode != CurveEditor.PickMode.Marquee)
     return;
   GUI.Label(EditorGUIExt.FromToRect(this.s_StartMouseDragPosition, this.s_EndMouseDragPosition), GUIContent.none, this.ms_Styles.selectionRect);
 }