Пример #1
0
 private void AddKeyToDopeline(DopeLine dopeLine)
 {
     this.state.ClearSelections();
     foreach (AnimationWindowCurve curve in dopeLine.m_Curves)
     {
         AnimationWindowKeyframe keyframe = AnimationWindowUtility.AddKeyframeToCurve(this.state, curve, this.state.time);
         this.state.SelectKey(keyframe);
     }
 }
        public List <AnimationWindowKeyframe> GetAggregateKeys(AnimationWindowHierarchyNode hierarchyNode)
        {
            DopeLine dopeLine = this.dopelines.FirstOrDefault((DopeLine e) => e.m_HierarchyNodeID == hierarchyNode.id);

            if (dopeLine == null)
            {
                return(null);
            }
            return(dopeLine.keys);
        }
 public bool AnyKeyIsSelected(DopeLine dopeline)
 {
     foreach (AnimationWindowKeyframe current in dopeline.keys)
     {
         if (this.KeyIsSelected(current))
         {
             return(true);
         }
     }
     return(false);
 }
Пример #4
0
 private bool AnyKeyIsSelectedAtTime(DopeLine dopeLine, int keyIndex)
 {
     int timeHash = dopeLine.keys[keyIndex].m_TimeHash;
     int count = dopeLine.keys.Count;
     for (int i = keyIndex; i < count; i++)
     {
         AnimationWindowKeyframe keyframe = dopeLine.keys[i];
         if (keyframe.m_TimeHash != timeHash)
         {
             return false;
         }
         if (this.state.KeyIsSelected(keyframe))
         {
             return true;
         }
     }
     return false;
 }
 private float GetKeyframeOffset(DopeLine dopeline, AnimationWindowKeyframe keyframe)
 {
   return dopeline.isPptrDopeline && dopeline.tallMode && (keyframe == null || keyframe.value != null) ? -1f : -5.5f;
 }
 private void HandleContextMenu(DopeLine dopeline)
 {
   if (!dopeline.position.Contains(Event.current.mousePosition))
     return;
   bool clickedEmpty = true;
   using (List<AnimationWindowKeyframe>.Enumerator enumerator = dopeline.keys.GetEnumerator())
   {
     while (enumerator.MoveNext())
     {
       AnimationWindowKeyframe current = enumerator.Current;
       if (this.GetKeyframeRect(dopeline, current).Contains(Event.current.mousePosition))
       {
         clickedEmpty = false;
         break;
       }
     }
   }
   this.GenerateMenu(dopeline, clickedEmpty).ShowAsContext();
 }
 private void HandleMouseDown(DopeLine dopeline)
 {
   Event current1 = Event.current;
   if (!EditorGUI.actionKey && !current1.shift)
   {
     using (List<AnimationWindowKeyframe>.Enumerator enumerator = dopeline.keys.GetEnumerator())
     {
       while (enumerator.MoveNext())
       {
         AnimationWindowKeyframe current2 = enumerator.Current;
         if (this.GetKeyframeRect(dopeline, current2).Contains(current1.mousePosition) && !this.state.KeyIsSelected(current2))
         {
           this.state.ClearSelections();
           break;
         }
       }
     }
   }
   float time = this.state.PixelToTime(Event.current.mousePosition.x);
   float num = time;
   if (Event.current.shift)
   {
     using (List<AnimationWindowKeyframe>.Enumerator enumerator = dopeline.keys.GetEnumerator())
     {
       while (enumerator.MoveNext())
       {
         AnimationWindowKeyframe current2 = enumerator.Current;
         if (this.state.KeyIsSelected(current2))
         {
           if ((double) current2.time < (double) time)
             time = current2.time;
           if ((double) current2.time > (double) num)
             num = current2.time;
         }
       }
     }
   }
   bool flag = false;
   using (List<AnimationWindowKeyframe>.Enumerator enumerator1 = dopeline.keys.GetEnumerator())
   {
     while (enumerator1.MoveNext())
     {
       AnimationWindowKeyframe current2 = enumerator1.Current;
       if (this.GetKeyframeRect(dopeline, current2).Contains(current1.mousePosition))
       {
         flag = true;
         if (!this.state.KeyIsSelected(current2))
         {
           if (Event.current.shift)
           {
             using (List<AnimationWindowKeyframe>.Enumerator enumerator2 = dopeline.keys.GetEnumerator())
             {
               while (enumerator2.MoveNext())
               {
                 AnimationWindowKeyframe current3 = enumerator2.Current;
                 if (current3 == current2 || (double) current3.time > (double) time && (double) current3.time < (double) num)
                   this.state.SelectKey(current3);
               }
             }
           }
           else
             this.state.SelectKey(current2);
           if (!dopeline.isMasterDopeline)
             this.state.SelectHierarchyItem(dopeline, EditorGUI.actionKey || current1.shift);
         }
         else if (EditorGUI.actionKey)
         {
           this.state.UnselectKey(current2);
           if (!this.state.AnyKeyIsSelected(dopeline))
             this.state.UnSelectHierarchyItem(dopeline);
         }
         this.state.activeKeyframe = current2;
         this.m_MousedownOnKeyframe = true;
         if (!this.state.playing)
           this.state.frame = this.state.TimeToFrameFloor(this.state.activeKeyframe.time);
         current1.Use();
       }
     }
   }
   if (dopeline.isMasterDopeline)
   {
     this.state.ClearHierarchySelection();
     using (List<int>.Enumerator enumerator = this.state.GetAffectedHierarchyIDs(this.state.selectedKeys).GetEnumerator())
     {
       while (enumerator.MoveNext())
         this.state.SelectHierarchyItem(enumerator.Current, true, true);
     }
   }
   if (!dopeline.position.Contains(Event.current.mousePosition))
     return;
   if (current1.clickCount == 2 && current1.button == 0 && (!Event.current.shift && !EditorGUI.actionKey))
     this.HandleDopelineDoubleclick(dopeline);
   if (current1.button != 1 || this.state.playing)
     return;
   this.state.frame = AnimationKeyTime.Time(this.state.PixelToTime(Event.current.mousePosition.x, true), this.state.frameRate).frame;
   if (flag)
     return;
   this.state.ClearSelections();
   this.m_IsDraggingPlayheadStarted = true;
   HandleUtility.Repaint();
   current1.Use();
 }
 private GenericMenu GenerateMenu(DopeLine dopeline, bool clickedEmpty)
 {
   GenericMenu menu = new GenericMenu();
   this.state.recording = true;
   this.state.ResampleAnimation();
   string text1 = "Add Key";
   if (clickedEmpty)
     menu.AddItem(new GUIContent(text1), false, new GenericMenu.MenuFunction2(this.AddKeyToDopeline), (object) dopeline);
   else
     menu.AddDisabledItem(new GUIContent(text1));
   string text2 = this.state.selectedKeys.Count <= 1 ? "Delete Key" : "Delete Keys";
   if (this.state.selectedKeys.Count > 0)
     menu.AddItem(new GUIContent(text2), false, new GenericMenu.MenuFunction(this.DeleteSelectedKeys));
   else
     menu.AddDisabledItem(new GUIContent(text2));
   if (AnimationWindowUtility.ContainsFloatKeyframes(this.state.selectedKeys))
   {
     menu.AddSeparator(string.Empty);
     List<KeyIdentifier> keyList = new List<KeyIdentifier>();
     using (List<AnimationWindowKeyframe>.Enumerator enumerator = this.state.selectedKeys.GetEnumerator())
     {
       while (enumerator.MoveNext())
       {
         AnimationWindowKeyframe current = enumerator.Current;
         if (!current.isPPtrCurve)
         {
           int keyframeIndex = current.curve.GetKeyframeIndex(AnimationKeyTime.Time(current.time, this.state.frameRate));
           if (keyframeIndex != -1)
           {
             CurveRenderer curveRenderer = CurveRendererCache.GetCurveRenderer(this.state.activeAnimationClip, current.curve.binding);
             int curveId = CurveUtility.GetCurveID(this.state.activeAnimationClip, current.curve.binding);
             keyList.Add(new KeyIdentifier(curveRenderer, curveId, keyframeIndex, current.curve.binding));
           }
         }
       }
     }
     new CurveMenuManager((CurveUpdater) this).AddTangentMenuItems(menu, keyList);
   }
   return menu;
 }
 private void DopeLineRepaint(DopeLine dopeline)
 {
   Color color1 = GUI.color;
   AnimationWindowHierarchyNode windowHierarchyNode = (AnimationWindowHierarchyNode) this.state.hierarchyData.FindItem(dopeline.m_HierarchyNodeID);
   Color color2 = windowHierarchyNode == null || windowHierarchyNode.depth <= 0 ? Color.gray.AlphaMultiplied(0.16f) : Color.gray.AlphaMultiplied(0.05f);
   if (!dopeline.isMasterDopeline)
     DopeSheetEditor.DrawBox(dopeline.position, color2);
   int? nullable = new int?();
   int count = dopeline.keys.Count;
   for (int keyIndex = 0; keyIndex < count; ++keyIndex)
   {
     AnimationWindowKeyframe key = dopeline.keys[keyIndex];
     if ((nullable.GetValueOrDefault() != key.m_TimeHash ? 0 : (nullable.HasValue ? 1 : 0)) == 0)
     {
       nullable = new int?(key.m_TimeHash);
       Rect rect = this.GetKeyframeRect(dopeline, key);
       Color color3 = !dopeline.isMasterDopeline ? Color.gray.RGBMultiplied(1.2f) : Color.gray.RGBMultiplied(0.85f);
       Texture2D texture = (Texture2D) null;
       if (key.isPPtrCurve && dopeline.tallMode)
         texture = key.value != null ? AssetPreview.GetAssetPreview(((UnityEngine.Object) key.value).GetInstanceID(), this.assetPreviewManagerID) : (Texture2D) null;
       if ((UnityEngine.Object) texture != (UnityEngine.Object) null)
       {
         rect = this.GetPreviewRectFromKeyFrameRect(rect);
         color3 = Color.white.AlphaMultiplied(0.5f);
       }
       else if (key.value != null && key.isPPtrCurve && dopeline.tallMode)
         this.m_SpritePreviewLoading = true;
       if (Mathf.Approximately(key.time, 0.0f))
         rect.xMin -= 0.01f;
       if (this.AnyKeyIsSelectedAtTime(dopeline, keyIndex))
       {
         Color color4 = !dopeline.tallMode || !dopeline.isPptrDopeline ? new Color(0.34f, 0.52f, 0.85f, 1f) : Color.white;
         if (dopeline.isMasterDopeline)
           color4 = color4.RGBMultiplied(0.85f);
         this.selectedKeysDrawBuffer.Add(new DopeSheetEditor.DrawElement(rect, color4, texture));
       }
       else
         this.unselectedKeysDrawBuffer.Add(new DopeSheetEditor.DrawElement(rect, color3, texture));
     }
   }
   if (this.state.clipIsEditable && this.DoDragAndDrop(dopeline, dopeline.position, false))
   {
     float time = Mathf.Max(this.state.PixelToTime(Event.current.mousePosition.x), 0.0f);
     Color color3 = Color.gray.RGBMultiplied(1.2f);
     Texture2D texture = (Texture2D) null;
     foreach (UnityEngine.Object dropObjectReference in this.GetSortedDragAndDropObjectReferences())
     {
       Rect rect = this.GetDragAndDropRect(dopeline, this.state.TimeToPixel(time));
       if (dopeline.isPptrDopeline && dopeline.tallMode)
         texture = AssetPreview.GetAssetPreview(dropObjectReference.GetInstanceID(), this.assetPreviewManagerID);
       if ((UnityEngine.Object) texture != (UnityEngine.Object) null)
       {
         rect = this.GetPreviewRectFromKeyFrameRect(rect);
         color3 = Color.white.AlphaMultiplied(0.5f);
       }
       this.dragdropKeysDrawBuffer.Add(new DopeSheetEditor.DrawElement(rect, color3, texture));
       time += 1f / this.state.frameRate;
     }
   }
   GUI.color = color1;
 }
		public void SelectHierarchyItem(DopeLine dopeline, bool additive, bool triggerSceneSelectionSync)
		{
			this.SelectHierarchyItem(dopeline.m_HierarchyNodeID, additive, triggerSceneSelectionSync);
		}
Пример #11
0
		private float GetKeyframeOffset(DopeLine dopeline)
		{
			if (dopeline.isPptrDopeline && dopeline.tallMode)
			{
				return -1f;
			}
			return -4f;
		}
 public void UnSelectHierarchyItem(DopeLine dopeline)
 {
     this.UnSelectHierarchyItem(dopeline.m_HierarchyNodeID);
 }
 public void SelectHierarchyItem(DopeLine dopeline, bool additive, bool triggerSceneSelectionSync)
 {
     this.SelectHierarchyItem(dopeline.m_HierarchyNodeID, additive, triggerSceneSelectionSync);
 }
 public void SelectHierarchyItem(DopeLine dopeline, bool additive)
 {
     this.SelectHierarchyItem(dopeline.m_HierarchyNodeID, additive, true);
 }
 private bool DoDragAndDrop(DopeLine dopeLine, bool perform)
 {
   return this.DoDragAndDrop(dopeLine, new Rect(), true, perform);
 }
 private AnimationWindowCurve GetCurveOfType(DopeLine dopeLine, System.Type type)
 {
   foreach (AnimationWindowCurve curve in dopeLine.m_Curves)
   {
     if (curve.m_ValueType == type)
       return curve;
   }
   return (AnimationWindowCurve) null;
 }
Пример #17
0
		private bool DoDragAndDrop(DopeLine dopeLine, bool perform)
		{
			return this.DoDragAndDrop(dopeLine, default(Rect), true, perform);
		}
		public void SelectHierarchyItem(DopeLine dopeline, bool additive)
		{
			this.SelectHierarchyItem(dopeline.m_HierarchyNodeID, additive, true);
		}
Пример #19
0
		private bool DoDragAndDrop(DopeLine dopeLine, Rect position, bool ignoreMousePosition, bool perform)
		{
			if (!ignoreMousePosition && !position.Contains(Event.current.mousePosition))
			{
				return false;
			}
			if (!DopeSheetEditor.ValidateDragAndDropObjects())
			{
				return false;
			}
			Type type = DragAndDrop.objectReferences[0].GetType();
			AnimationWindowCurve animationWindowCurve = null;
			if (dopeLine.valueType == type)
			{
				animationWindowCurve = dopeLine.m_Curves[0];
			}
			else
			{
				AnimationWindowCurve[] curves = dopeLine.m_Curves;
				for (int i = 0; i < curves.Length; i++)
				{
					AnimationWindowCurve animationWindowCurve2 = curves[i];
					if (animationWindowCurve2.isPPtrCurve)
					{
						if (animationWindowCurve2.m_ValueType == type)
						{
							animationWindowCurve = animationWindowCurve2;
						}
						if (animationWindowCurve2.m_ValueType == typeof(Sprite) && SpriteUtility.GetSpriteFromDraggedPathsOrObjects() != null)
						{
							animationWindowCurve = animationWindowCurve2;
							type = typeof(Sprite);
						}
					}
				}
			}
			bool result = true;
			if (animationWindowCurve != null)
			{
				if (perform)
				{
					if (DragAndDrop.objectReferences.Length == 1)
					{
						Analytics.Event("Sprite Drag and Drop", "Drop single sprite into existing dopeline", "null", 1);
					}
					else
					{
						Analytics.Event("Sprite Drag and Drop", "Drop multiple sprites into existing dopeline", "null", 1);
					}
					Rect dragAndDropRect = this.GetDragAndDropRect(dopeLine, Event.current.mousePosition.x);
					float time = Mathf.Max(this.state.PixelToTime(dragAndDropRect.xMin, true), 0f);
					AnimationWindowCurve curveOfType = this.GetCurveOfType(dopeLine, type);
					this.PeformDragAndDrop(curveOfType, time);
				}
			}
			else
			{
				result = false;
			}
			return result;
		}
		public void UnSelectHierarchyItem(DopeLine dopeline)
		{
			this.UnSelectHierarchyItem(dopeline.m_HierarchyNodeID);
		}
Пример #21
0
		private AnimationWindowCurve GetCurveOfType(DopeLine dopeLine, Type type)
		{
			AnimationWindowCurve[] curves = dopeLine.m_Curves;
			for (int i = 0; i < curves.Length; i++)
			{
				AnimationWindowCurve animationWindowCurve = curves[i];
				if (animationWindowCurve.m_ValueType == type)
				{
					return animationWindowCurve;
				}
			}
			return null;
		}
 private Rect GetDragAndDropRect(DopeLine dopeline, float screenX)
 {
   Rect keyframeRect = this.GetKeyframeRect(dopeline, (AnimationWindowKeyframe) null);
   float keyframeOffset = this.GetKeyframeOffset(dopeline, (AnimationWindowKeyframe) null);
   float time = Mathf.Max(this.state.PixelToTime(screenX - keyframeRect.width * 0.5f, true), 0.0f);
   keyframeRect.center = new Vector2(this.state.TimeToPixel(time) + keyframeRect.width * 0.5f + keyframeOffset, keyframeRect.center.y);
   return keyframeRect;
 }
Пример #23
0
		private void AddKeyToDopeline(DopeLine dopeLine)
		{
			this.state.ClearKeySelections();
			AnimationWindowCurve[] curves = dopeLine.m_Curves;
			for (int i = 0; i < curves.Length; i++)
			{
				AnimationWindowCurve curve = curves[i];
				AnimationWindowKeyframe keyframe = AnimationWindowUtility.AddKeyframeToCurve(this.state, curve, this.state.time);
				this.state.SelectKey(keyframe);
			}
		}
 private void HandleDragAndDrop(DopeLine dopeline)
 {
   Event current = Event.current;
   if (current.type != EventType.DragPerform && current.type != EventType.DragUpdated)
     return;
   if (this.DoDragAndDrop(dopeline, dopeline.position, current.type == EventType.DragPerform))
   {
     DragAndDrop.visualMode = DragAndDropVisualMode.Copy;
     current.Use();
   }
   else
     DragAndDrop.visualMode = DragAndDropVisualMode.Rejected;
 }
Пример #25
0
		private void DopeLineRepaint(DopeLine dopeline)
		{
			Color color = GUI.color;
			AnimationWindowHierarchyNode animationWindowHierarchyNode = (AnimationWindowHierarchyNode)this.state.m_HierarchyData.FindItem(dopeline.m_HierarchyNodeID);
			bool flag = animationWindowHierarchyNode != null && animationWindowHierarchyNode.depth > 0;
			Color color2 = (!flag) ? Color.gray.AlphaMultiplied(0.16f) : Color.gray.AlphaMultiplied(0.05f);
			if (!dopeline.isMasterDopeline)
			{
				DopeSheetEditor.DrawBox(dopeline.position, color2);
			}
			else
			{
				AnimationWindow.ms_Styles.eventBackground.Draw(dopeline.position, false, false, false, false);
			}
			int? num = null;
			int count = dopeline.keys.Count;
			for (int i = 0; i < count; i++)
			{
				AnimationWindowKeyframe animationWindowKeyframe = dopeline.keys[i];
				if (!(num == animationWindowKeyframe.m_TimeHash))
				{
					num = new int?(animationWindowKeyframe.m_TimeHash);
					Rect rect = this.GetKeyframeRect(dopeline, animationWindowKeyframe);
					color2 = ((!dopeline.isMasterDopeline) ? Color.gray.RGBMultiplied(1.2f) : Color.gray.RGBMultiplied(0.85f));
					Texture2D texture2D = null;
					if (animationWindowKeyframe.isPPtrCurve && dopeline.tallMode)
					{
						texture2D = ((animationWindowKeyframe.value != null) ? AssetPreview.GetAssetPreview(((UnityEngine.Object)animationWindowKeyframe.value).GetInstanceID(), this.assetPreviewManagerID) : null);
					}
					if (texture2D != null)
					{
						rect = this.GetPreviewRectFromKeyFrameRect(rect);
						color2 = Color.white.AlphaMultiplied(0.5f);
					}
					else
					{
						if (animationWindowKeyframe.value != null && animationWindowKeyframe.isPPtrCurve && dopeline.tallMode)
						{
							this.m_SpritePreviewLoading = true;
						}
					}
					if (Application.platform == RuntimePlatform.WindowsEditor)
					{
						rect.xMin -= 0.01f;
					}
					if (this.AnyKeyIsSelectedAtTime(dopeline, i))
					{
						color2 = ((!dopeline.tallMode || !dopeline.isPptrDopeline) ? new Color(0.34f, 0.52f, 0.85f, 1f) : Color.white);
						if (dopeline.isMasterDopeline)
						{
							color2 = color2.RGBMultiplied(0.85f);
						}
						this.selectedKeysDrawBuffer.Add(new DopeSheetEditor.DrawElement(rect, color2, texture2D));
					}
					else
					{
						this.unselectedKeysDrawBuffer.Add(new DopeSheetEditor.DrawElement(rect, color2, texture2D));
					}
				}
			}
			if (this.state.IsClipEditable && this.DoDragAndDrop(dopeline, dopeline.position, false))
			{
				float num2 = Mathf.Max(this.state.PixelToTime(Event.current.mousePosition.x), 0f);
				Color color3 = Color.gray.RGBMultiplied(1.2f);
				Texture2D texture2D2 = null;
				UnityEngine.Object[] sortedDragAndDropObjectReferences = this.GetSortedDragAndDropObjectReferences();
				for (int j = 0; j < sortedDragAndDropObjectReferences.Length; j++)
				{
					UnityEngine.Object @object = sortedDragAndDropObjectReferences[j];
					Rect rect2 = this.GetDragAndDropRect(dopeline, this.state.TimeToPixel(num2));
					if (dopeline.isPptrDopeline && dopeline.tallMode)
					{
						texture2D2 = AssetPreview.GetAssetPreview(@object.GetInstanceID(), this.assetPreviewManagerID);
					}
					if (texture2D2 != null)
					{
						rect2 = this.GetPreviewRectFromKeyFrameRect(rect2);
						color3 = Color.white.AlphaMultiplied(0.5f);
					}
					this.dragdropKeysDrawBuffer.Add(new DopeSheetEditor.DrawElement(rect2, color3, texture2D2));
					num2 += 1f / this.state.frameRate;
				}
			}
			GUI.color = color;
		}
 private void HandleDopelineDoubleclick(DopeLine dopeline)
 {
   this.state.ClearSelections();
   AnimationKeyTime time = AnimationKeyTime.Time(this.state.PixelToTime(Event.current.mousePosition.x, true), this.state.frameRate);
   foreach (AnimationWindowCurve curve in dopeline.m_Curves)
     this.state.SelectKey(AnimationWindowUtility.AddKeyframeToCurve(this.state, curve, time));
   if (!this.state.playing)
     this.state.frame = time.frame;
   Event.current.Use();
 }
Пример #27
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;
		}
 private Rect GetKeyframeRect(DopeLine dopeline, AnimationWindowKeyframe keyframe)
 {
   float time = keyframe == null ? 0.0f : keyframe.time;
   float width = 10f;
   if (dopeline.isPptrDopeline && dopeline.tallMode && (keyframe == null || keyframe.value != null))
     width = dopeline.position.height;
   if (dopeline.isPptrDopeline && dopeline.tallMode)
     return new Rect(this.state.TimeToPixel(this.state.SnapToFrame(time)) + this.GetKeyframeOffset(dopeline, keyframe), dopeline.position.yMin, width, dopeline.position.height);
   return new Rect(this.state.TimeToPixel(this.state.SnapToFrame(time)) + this.GetKeyframeOffset(dopeline, keyframe), dopeline.position.yMin, width, dopeline.position.height);
 }
Пример #29
0
		private void HandleMouseDown(DopeLine dopeline)
		{
			Event current = Event.current;
			this.state.m_AnimationWindow.EnsureAnimationMode();
			if (!current.control && !current.shift)
			{
				foreach (AnimationWindowKeyframe current2 in dopeline.keys)
				{
					if (this.GetKeyframeRect(dopeline, current2).Contains(current.mousePosition) && !this.state.KeyIsSelected(current2))
					{
						this.state.ClearKeySelections();
						break;
					}
				}
			}
			float num = this.state.PixelToTime(Event.current.mousePosition.x);
			float num2 = num;
			if (Event.current.shift)
			{
				foreach (AnimationWindowKeyframe current3 in dopeline.keys)
				{
					if (this.state.KeyIsSelected(current3))
					{
						if (current3.time < num)
						{
							num = current3.time;
						}
						if (current3.time > num2)
						{
							num2 = current3.time;
						}
					}
				}
			}
			bool flag = false;
			foreach (AnimationWindowKeyframe current4 in dopeline.keys)
			{
				if (this.GetKeyframeRect(dopeline, current4).Contains(current.mousePosition))
				{
					flag = true;
					if (!this.state.KeyIsSelected(current4))
					{
						if (Event.current.shift)
						{
							foreach (AnimationWindowKeyframe current5 in dopeline.keys)
							{
								if (current5 == current4 || (current5.time > num && current5.time < num2))
								{
									this.state.SelectKey(current5);
								}
							}
						}
						else
						{
							this.state.SelectKey(current4);
						}
						if (!dopeline.isMasterDopeline)
						{
							this.state.SelectHierarchyItem(dopeline, current.control || current.shift);
						}
					}
					else
					{
						if (current.control)
						{
							this.state.UnselectKey(current4);
						}
					}
					this.state.activeKeyframe = current4;
					this.m_MousedownOnKeyframe = true;
					this.state.m_Frame = this.state.TimeToFrameFloor(this.state.activeKeyframe.time);
					current.Use();
				}
			}
			if (dopeline.isMasterDopeline)
			{
				this.state.ClearHierarchySelection();
				List<int> affectedHierarchyIDs = this.state.GetAffectedHierarchyIDs(this.state.selectedKeys);
				foreach (int current6 in affectedHierarchyIDs)
				{
					this.state.SelectHierarchyItem(current6, true, true);
				}
			}
			if (dopeline.position.Contains(Event.current.mousePosition))
			{
				if (current.clickCount == 2 && current.button == 0 && !Event.current.shift && !Event.current.control)
				{
					this.HandleDopelineDoubleclick(dopeline);
				}
				if (current.button == 1)
				{
					float time = this.state.PixelToTime(Event.current.mousePosition.x, true);
					AnimationKeyTime animationKeyTime = AnimationKeyTime.Time(time, this.state.frameRate);
					this.state.m_Frame = animationKeyTime.frame;
					if (!flag)
					{
						this.state.ClearKeySelections();
						this.m_IsDraggingPlayheadStarted = true;
						HandleUtility.Repaint();
						current.Use();
					}
				}
			}
		}
 private bool DoDragAndDrop(DopeLine dopeLine, Rect position, bool perform)
 {
   return this.DoDragAndDrop(dopeLine, position, false, perform);
 }
Пример #31
0
		private void HandleDopelineDoubleclick(DopeLine dopeline)
		{
			this.state.ClearKeySelections();
			float time = this.state.PixelToTime(Event.current.mousePosition.x, true);
			AnimationKeyTime time2 = AnimationKeyTime.Time(time, this.state.frameRate);
			AnimationWindowCurve[] curves = dopeline.m_Curves;
			for (int i = 0; i < curves.Length; i++)
			{
				AnimationWindowCurve curve = curves[i];
				AnimationWindowKeyframe keyframe = AnimationWindowUtility.AddKeyframeToCurve(this.state, curve, time2);
				this.state.SelectKey(keyframe);
			}
			this.state.m_Frame = time2.frame;
			Event.current.Use();
		}
 private bool DoDragAndDrop(DopeLine dopeLine, Rect position, bool ignoreMousePosition, bool perform)
 {
   if (!ignoreMousePosition && !position.Contains(Event.current.mousePosition) || !DopeSheetEditor.ValidateDragAndDropObjects())
     return false;
   System.Type type = DragAndDrop.objectReferences[0].GetType();
   AnimationWindowCurve animationWindowCurve = (AnimationWindowCurve) null;
   if (dopeLine.valueType == type)
   {
     animationWindowCurve = dopeLine.m_Curves[0];
   }
   else
   {
     foreach (AnimationWindowCurve curve in dopeLine.m_Curves)
     {
       if (curve.isPPtrCurve)
       {
         if (curve.m_ValueType == type)
           animationWindowCurve = curve;
         Sprite[] draggedPathsOrObjects = SpriteUtility.GetSpriteFromDraggedPathsOrObjects();
         if (curve.m_ValueType == typeof (Sprite) && draggedPathsOrObjects != null && draggedPathsOrObjects.Length > 0)
         {
           animationWindowCurve = curve;
           type = typeof (Sprite);
         }
       }
     }
   }
   bool flag = true;
   if (animationWindowCurve != null)
   {
     if (perform)
     {
       if (DragAndDrop.objectReferences.Length == 1)
         Analytics.Event("Sprite Drag and Drop", "Drop single sprite into existing dopeline", "null", 1);
       else
         Analytics.Event("Sprite Drag and Drop", "Drop multiple sprites into existing dopeline", "null", 1);
       float time = Mathf.Max(this.state.PixelToTime(this.GetDragAndDropRect(dopeLine, Event.current.mousePosition.x).xMin, true), 0.0f);
       this.PeformDragAndDrop(this.GetCurveOfType(dopeLine, type), time);
     }
   }
   else
     flag = false;
   return flag;
 }
Пример #33
0
		private void HandleContextMenu(DopeLine dopeline)
		{
			if (!dopeline.position.Contains(Event.current.mousePosition))
			{
				return;
			}
			bool clickedEmpty = true;
			foreach (AnimationWindowKeyframe current in dopeline.keys)
			{
				if (this.GetKeyframeRect(dopeline, current).Contains(Event.current.mousePosition))
				{
					clickedEmpty = false;
					break;
				}
			}
			this.state.m_AnimationWindow.RefreshShownCurves(true);
			this.GenerateMenu(dopeline, clickedEmpty).ShowAsContext();
		}
 private bool AnyKeyIsSelectedAtTime(DopeLine dopeLine, int keyIndex)
 {
   int timeHash = dopeLine.keys[keyIndex].m_TimeHash;
   int count = dopeLine.keys.Count;
   for (int index = keyIndex; index < count; ++index)
   {
     AnimationWindowKeyframe key = dopeLine.keys[index];
     if (key.m_TimeHash != timeHash)
       return false;
     if (this.state.KeyIsSelected(key))
       return true;
   }
   return false;
 }
		public bool AnyKeyIsSelected(DopeLine dopeline)
		{
			foreach (AnimationWindowKeyframe current in dopeline.keys)
			{
				if (this.KeyIsSelected(current))
				{
					return true;
				}
			}
			return false;
		}