コード例 #1
0
		private GenericMenu GenerateMenu(DopeLine dopeline, bool clickedEmpty)
		{
			GenericMenu genericMenu = new GenericMenu();
			if (AnimationMode.InAnimationMode())
			{
				string text = "Add Key";
				if (clickedEmpty)
				{
					genericMenu.AddItem(new GUIContent(text), false, new GenericMenu.MenuFunction2(this.AddKeyToDopeline), dopeline);
				}
				else
				{
					genericMenu.AddDisabledItem(new GUIContent(text));
				}
				text = ((this.state.selectedKeys.Count <= 1) ? "Delete Key" : "Delete Keys");
				if (this.state.selectedKeys.Count > 0)
				{
					genericMenu.AddItem(new GUIContent(text), false, new GenericMenu.MenuFunction(this.DeleteSelectedKeys));
				}
				else
				{
					genericMenu.AddDisabledItem(new GUIContent(text));
				}
				if (AnimationWindowUtility.ContainsFloatKeyframes(this.state.selectedKeys))
				{
					genericMenu.AddSeparator(string.Empty);
					List<KeyIdentifier> list = new List<KeyIdentifier>();
					foreach (AnimationWindowKeyframe current in this.state.selectedKeys)
					{
						if (!current.isPPtrCurve)
						{
							int keyframeIndex = current.curve.GetKeyframeIndex(AnimationKeyTime.Time(current.time, this.state.frameRate));
							if (keyframeIndex != -1)
							{
								CurveRenderer curveRenderer = CurveRendererCache.GetCurveRenderer(this.state.m_ActiveAnimationClip, current.curve.binding);
								int curveID = CurveUtility.GetCurveID(this.state.m_ActiveAnimationClip, current.curve.binding);
								list.Add(new KeyIdentifier(curveRenderer, curveID, keyframeIndex));
							}
						}
					}
					CurveMenuManager curveMenuManager = new CurveMenuManager(this.state.m_AnimationWindow);
					curveMenuManager.AddTangentMenuItems(genericMenu, list);
				}
			}
			return genericMenu;
		}
コード例 #2
0
 public void CurveGUI()
 {
   this.InitStyles();
   GUI.BeginGroup(this.drawRect);
   this.Init();
   GUIUtility.GetControlID(CurveEditor.s_SelectKeyHash, FocusType.Passive);
   Color white = Color.white;
   GUI.backgroundColor = white;
   GUI.contentColor = white;
   Color color = GUI.color;
   Event current1 = Event.current;
   if (current1.type != EventType.Repaint)
     this.EditSelectedPoints();
   EventType type = current1.type;
   switch (type)
   {
     case EventType.KeyDown:
       if ((current1.keyCode == KeyCode.Backspace || current1.keyCode == KeyCode.Delete) && this.hasSelection)
       {
         this.DeleteSelectedPoints();
         current1.Use();
         break;
       }
       break;
     case EventType.Repaint:
       this.DrawCurves(this.animationCurves);
       break;
     default:
       switch (type - 13)
       {
         case EventType.MouseDown:
         case EventType.MouseUp:
           bool flag1 = current1.type == EventType.ExecuteCommand;
           string commandName = current1.commandName;
           if (commandName != null)
           {
             // ISSUE: reference to a compiler-generated field
             if (CurveEditor.\u003C\u003Ef__switch\u0024mapC == null)
             {
               // ISSUE: reference to a compiler-generated field
               CurveEditor.\u003C\u003Ef__switch\u0024mapC = new Dictionary<string, int>(3)
               {
                 {
                   "Delete",
                   0
                 },
                 {
                   "FrameSelected",
                   1
                 },
                 {
                   "SelectAll",
                   2
                 }
               };
             }
             int num;
             // ISSUE: reference to a compiler-generated field
             if (CurveEditor.\u003C\u003Ef__switch\u0024mapC.TryGetValue(commandName, out num))
             {
               switch (num)
               {
                 case 0:
                   if (this.hasSelection)
                   {
                     if (flag1)
                       this.DeleteSelectedPoints();
                     current1.Use();
                     break;
                   }
                   break;
                 case 1:
                   if (flag1)
                     this.FrameSelected(true, true);
                   current1.Use();
                   break;
                 case 2:
                   if (flag1)
                     this.SelectAll();
                   current1.Use();
                   break;
               }
             }
             else
               break;
           }
           else
             break;
         case EventType.MouseDrag:
           CurveSelection nearest = this.FindNearest();
           if (nearest != null)
           {
             List<KeyIdentifier> keyList = new List<KeyIdentifier>();
             bool flag2 = false;
             using (List<CurveSelection>.Enumerator enumerator = this.selectedCurves.GetEnumerator())
             {
               while (enumerator.MoveNext())
               {
                 CurveSelection current2 = enumerator.Current;
                 keyList.Add(new KeyIdentifier(current2.curveWrapper.renderer, current2.curveID, current2.key));
                 if (current2.curveID == nearest.curveID && current2.key == nearest.key)
                   flag2 = true;
               }
             }
             if (!flag2)
             {
               keyList.Clear();
               keyList.Add(new KeyIdentifier(nearest.curveWrapper.renderer, nearest.curveID, nearest.key));
               this.ClearSelection();
               this.AddSelection(nearest);
             }
             this.m_MenuManager = new CurveMenuManager((CurveUpdater) this);
             GenericMenu menu = new GenericMenu();
             menu.AddItem(new GUIContent(keyList.Count <= 1 ? "Delete Key" : "Delete Keys"), false, new GenericMenu.MenuFunction2(this.DeleteKeys), (object) keyList);
             menu.AddItem(new GUIContent(keyList.Count <= 1 ? "Edit Key..." : "Edit Keys..."), false, new GenericMenu.MenuFunction2(this.StartEditingSelectedPointsContext), (object) this.mousePositionInDrawing);
             menu.AddSeparator(string.Empty);
             this.m_MenuManager.AddTangentMenuItems(menu, keyList);
             menu.ShowAsContext();
             Event.current.Use();
             break;
           }
           break;
       }
   }
   if (current1.type == EventType.Repaint)
     this.EditSelectedPoints();
   EditorGUI.BeginChangeCheck();
   GUI.color = color;
   this.DragTangents();
   this.EditAxisLabels();
   this.SelectPoints();
   if (EditorGUI.EndChangeCheck())
   {
     this.RecalcSecondarySelection();
     this.RecalcCurveSelection();
   }
   EditorGUI.BeginChangeCheck();
   Vector2 vector2 = this.MovePoints();
   if (EditorGUI.EndChangeCheck() && this.m_DraggingKey != null)
   {
     this.activeTime = vector2.x + this.s_StartClickedTime;
     this.m_MoveCoord = vector2;
   }
   GUI.color = color;
   GUI.EndGroup();
 }
コード例 #3
0
		public void CurveGUI()
		{
			this.InitStyles();
			GUI.BeginGroup(base.drawRect);
			this.Init();
			GUIUtility.GetControlID(CurveEditor.s_SelectKeyHash, FocusType.Passive);
			Color white = Color.white;
			GUI.backgroundColor = white;
			GUI.contentColor = white;
			Color color = GUI.color;
			Event current = Event.current;
			EventType type = current.type;
			switch (type)
			{
			case EventType.KeyDown:
				if ((current.keyCode == KeyCode.Backspace || current.keyCode == KeyCode.Delete) && this.hasSelection)
				{
					this.DeleteSelectedPoints();
					current.Use();
				}
				goto IL_30C;
			case EventType.KeyUp:
			case EventType.ScrollWheel:
				IL_65:
				switch (type)
				{
				case EventType.ValidateCommand:
				case EventType.ExecuteCommand:
				{
					bool flag = current.type == EventType.ExecuteCommand;
					string commandName = current.commandName;
					switch (commandName)
					{
					case "Delete":
						if (this.hasSelection)
						{
							if (flag)
							{
								this.DeleteSelectedPoints();
							}
							current.Use();
						}
						break;
					case "FrameSelected":
						if (flag)
						{
							this.FrameSelected(true, true);
						}
						current.Use();
						break;
					case "SelectAll":
						if (flag)
						{
							this.SelectAll();
						}
						current.Use();
						break;
					}
					goto IL_30C;
				}
				case EventType.DragExited:
					goto IL_30C;
				case EventType.ContextClick:
				{
					CurveSelection curveSelection = this.FindNearest();
					if (curveSelection != null)
					{
						List<KeyIdentifier> list = new List<KeyIdentifier>();
						bool flag2 = false;
						foreach (CurveSelection current2 in this.m_Selection)
						{
							list.Add(new KeyIdentifier(current2.curveWrapper.renderer, current2.curveID, current2.key));
							if (current2.curveID == curveSelection.curveID && current2.key == curveSelection.key)
							{
								flag2 = true;
							}
						}
						if (!flag2)
						{
							list.Clear();
							list.Add(new KeyIdentifier(curveSelection.curveWrapper.renderer, curveSelection.curveID, curveSelection.key));
							this.m_Selection.Clear();
							this.m_Selection.Add(curveSelection);
						}
						this.m_MenuManager = new CurveMenuManager(this);
						GenericMenu genericMenu = new GenericMenu();
						string text;
						if (list.Count > 1)
						{
							text = "Delete Keys";
						}
						else
						{
							text = "Delete Key";
						}
						genericMenu.AddItem(new GUIContent(text), false, new GenericMenu.MenuFunction2(this.DeleteKeys), list);
						genericMenu.AddSeparator(string.Empty);
						this.m_MenuManager.AddTangentMenuItems(genericMenu, list);
						genericMenu.ShowAsContext();
						Event.current.Use();
					}
					goto IL_30C;
				}
				default:
					goto IL_30C;
				}
				break;
			case EventType.Repaint:
				this.DrawCurves(this.animationCurves);
				goto IL_30C;
			}
			goto IL_65;
			IL_30C:
			bool changed = GUI.changed;
			GUI.changed = false;
			GUI.color = color;
			this.DragTangents();
			this.EditAxisLabels();
			this.SelectPoints();
			if (GUI.changed)
			{
				this.RecalcSecondarySelection();
				this.RecalcCurveSelection();
			}
			GUI.changed = false;
			Vector2 moveCoord = this.MovePoints();
			if (GUI.changed && this.m_DraggingKey != null)
			{
				this.activeTime = moveCoord.x + this.s_StartClickedTime;
				this.m_MoveCoord = moveCoord;
			}
			GUI.changed = changed;
			GUI.color = color;
			GUI.EndGroup();
		}
コード例 #4
0
		private GenericMenu GenerateMenu(List<AnimationWindowHierarchyNode> interactedNodes)
		{
			List<AnimationWindowCurve> curvesAffectedByNodes = this.GetCurvesAffectedByNodes(interactedNodes, false);
			List<AnimationWindowCurve> curvesAffectedByNodes2 = this.GetCurvesAffectedByNodes(interactedNodes, true);
			bool flag = curvesAffectedByNodes.Count == 1 && AnimationWindowUtility.ForceGrouping(curvesAffectedByNodes[0].binding);
			GenericMenu genericMenu = new GenericMenu();
			genericMenu.AddItem(new GUIContent((curvesAffectedByNodes.Count <= 1 && !flag) ? "Remove Property" : "Remove Properties"), false, new GenericMenu.MenuFunction(this.RemoveCurvesFromSelectedNodes));
			bool flag2 = true;
			EditorCurveBinding[] array = new EditorCurveBinding[curvesAffectedByNodes2.Count];
			for (int i = 0; i < curvesAffectedByNodes2.Count; i++)
			{
				array[i] = curvesAffectedByNodes2[i].binding;
			}
			RotationCurveInterpolation.Mode rotationInterpolationMode = this.GetRotationInterpolationMode(array);
			if (rotationInterpolationMode == RotationCurveInterpolation.Mode.Undefined)
			{
				flag2 = false;
			}
			else
			{
				foreach (AnimationWindowHierarchyNode current in interactedNodes)
				{
					if (!(current is AnimationWindowHierarchyPropertyGroupNode))
					{
						flag2 = false;
					}
				}
			}
			if (flag2)
			{
				genericMenu.AddItem(new GUIContent("Interpolation/Euler Angles"), rotationInterpolationMode == RotationCurveInterpolation.Mode.Baked, new GenericMenu.MenuFunction2(this.ChangeRotationInterpolation), RotationCurveInterpolation.Mode.Baked);
				genericMenu.AddItem(new GUIContent("Interpolation/Quaternion"), rotationInterpolationMode == RotationCurveInterpolation.Mode.NonBaked, new GenericMenu.MenuFunction2(this.ChangeRotationInterpolation), RotationCurveInterpolation.Mode.NonBaked);
			}
			if (AnimationMode.InAnimationMode())
			{
				genericMenu.AddSeparator(string.Empty);
				bool flag3 = true;
				bool flag4 = true;
				bool flag5 = true;
				foreach (AnimationWindowCurve current2 in curvesAffectedByNodes)
				{
					if (!current2.HasKeyframe(this.state.time))
					{
						flag3 = false;
					}
					else
					{
						flag4 = false;
						if (!current2.isPPtrCurve)
						{
							flag5 = false;
						}
					}
				}
				string text = "Add Key";
				if (flag3)
				{
					genericMenu.AddDisabledItem(new GUIContent(text));
				}
				else
				{
					genericMenu.AddItem(new GUIContent(text), false, new GenericMenu.MenuFunction2(this.AddKeysAtCurrentTime), curvesAffectedByNodes);
				}
				text = "Delete Key";
				if (flag4)
				{
					genericMenu.AddDisabledItem(new GUIContent(text));
				}
				else
				{
					genericMenu.AddItem(new GUIContent(text), false, new GenericMenu.MenuFunction2(this.DeleteKeysAtCurrentTime), curvesAffectedByNodes);
				}
				if (!flag5)
				{
					genericMenu.AddSeparator(string.Empty);
					List<KeyIdentifier> list = new List<KeyIdentifier>();
					foreach (AnimationWindowCurve current3 in curvesAffectedByNodes)
					{
						if (!current3.isPPtrCurve)
						{
							int keyframeIndex = current3.GetKeyframeIndex(this.state.time);
							if (keyframeIndex != -1)
							{
								CurveRenderer curveRenderer = CurveRendererCache.GetCurveRenderer(this.state.m_ActiveAnimationClip, current3.binding);
								int curveID = CurveUtility.GetCurveID(this.state.m_ActiveAnimationClip, current3.binding);
								list.Add(new KeyIdentifier(curveRenderer, curveID, keyframeIndex));
							}
						}
					}
					CurveMenuManager curveMenuManager = new CurveMenuManager(this.state.m_AnimationWindow);
					curveMenuManager.AddTangentMenuItems(genericMenu, list);
				}
			}
			return genericMenu;
		}