Inheritance: IComparable
コード例 #1
0
 internal CurveSelection(int curveID, CurveEditor host, int keyIndex, CurveSelection.SelectionType t)
 {
   this.m_CurveID = curveID;
   this.m_Host = host;
   this.m_Key = keyIndex;
   this.type = t;
 }
コード例 #2
0
        public override bool Equals(object _other)
        {
            CurveSelection curveSelection = (CurveSelection)_other;

            if (curveSelection.curveID == this.curveID && curveSelection.key == this.key)
            {
                return(curveSelection.type == this.type);
            }
            return(false);
        }
コード例 #3
0
ファイル: AnimEditor.cs プロジェクト: yiifans/UnityDecompiled
 private void UpdateSelectedKeysToCurveEditor()
 {
     this.m_CurveEditor.ClearSelection();
     foreach (AnimationWindowKeyframe current in this.m_State.selectedKeys)
     {
         CurveSelection curveSelection = AnimationWindowUtility.AnimationWindowKeyframeToCurveSelection(current, this.m_CurveEditor);
         if (curveSelection != null)
         {
             this.m_CurveEditor.AddSelection(curveSelection);
         }
     }
 }
コード例 #4
0
        public override bool Equals(object _other)
        {
            CurveSelection other = _other as CurveSelection;

            if (ReferenceEquals(other, null))
            {
                return(false);
            }
            if (ReferenceEquals(other, this))
            {
                return(true);
            }
            return(other.curveID == curveID && other.key == key && other.type == type);
        }
コード例 #5
0
 private void UpdateSelectedKeysToCurveEditor()
 {
     this.m_CurveEditor.ClearSelection();
     using (List <AnimationWindowKeyframe> .Enumerator enumerator = this.m_State.selectedKeys.GetEnumerator())
     {
         while (enumerator.MoveNext())
         {
             CurveSelection curveSelection = AnimationWindowUtility.AnimationWindowKeyframeToCurveSelection(enumerator.Current, this.m_CurveEditor);
             if (curveSelection != null)
             {
                 this.m_CurveEditor.AddSelection(curveSelection);
             }
         }
     }
 }
コード例 #6
0
        public int CompareTo(object _other)
        {
            CurveSelection curveSelection = (CurveSelection)_other;
            int            num            = this.curveID - curveSelection.curveID;

            if (num != 0)
            {
                return(num);
            }
            num = this.key - curveSelection.key;
            if (num != 0)
            {
                return(num);
            }
            return(this.type - curveSelection.type);
        }
コード例 #7
0
        // We sync keyframe selection from AnimationWindowState to curve editor
        private void UpdateSelectedKeysToCurveEditor()
        {
            UpdateCurveEditorData();

            m_CurveEditor.ClearSelection();
            m_CurveEditor.BeginRangeSelection();
            foreach (AnimationWindowKeyframe keyframe in m_State.selectedKeys)
            {
                CurveSelection curveSelection = AnimationWindowUtility.AnimationWindowKeyframeToCurveSelection(keyframe, m_CurveEditor);
                if (curveSelection != null)
                {
                    m_CurveEditor.AddSelection(curveSelection);
                }
            }
            m_CurveEditor.EndRangeSelection();
        }
コード例 #8
0
        public int CompareTo(object _other)
        {
            CurveSelection other = (CurveSelection)_other;
            int            cmp   = curveID - other.curveID;

            if (cmp != 0)
            {
                return(cmp);
            }

            cmp = key - other.key;
            if (cmp != 0)
            {
                return(cmp);
            }

            return((int)type - (int)other.type);
        }
コード例 #9
0
        public int CompareTo(object _other)
        {
            CurveSelection curveSelection = (CurveSelection)_other;
            int            num            = this.curveID - curveSelection.curveID;
            int            result;

            if (num != 0)
            {
                result = num;
            }
            else
            {
                num = this.key - curveSelection.key;
                if (num != 0)
                {
                    result = num;
                }
                else
                {
                    result = this.type - curveSelection.type;
                }
            }
            return(result);
        }
コード例 #10
0
 public static AnimationWindowKeyframe CurveSelectionToAnimationWindowKeyframe(CurveSelection curveSelection, List<AnimationWindowCurve> allCurves)
 {
   using (List<AnimationWindowCurve>.Enumerator enumerator = allCurves.GetEnumerator())
   {
     while (enumerator.MoveNext())
     {
       AnimationWindowCurve current = enumerator.Current;
       if (current.binding == curveSelection.curveWrapper.binding && current.m_Keyframes.Count > curveSelection.key)
         return current.m_Keyframes[curveSelection.key];
     }
   }
   return (AnimationWindowKeyframe) null;
 }
コード例 #11
0
ファイル: CurveSelection.cs プロジェクト: randomize/VimConfig
        public override bool Equals(object _other)
        {
            CurveSelection selection = (CurveSelection)_other;

            return(((selection.curveID == this.curveID) && (selection.key == this.key)) && (selection.type == this.type));
        }
コード例 #12
0
		public void UpdateCurvesFromPoints(Vector2 movement)
		{
			this.m_DisplayedSelection = new List<CurveSelection>();
			foreach (CurveEditor.SavedCurve current in this.m_CurveBackups)
			{
				List<CurveEditor.SavedCurve.SavedKeyFrame> list = new List<CurveEditor.SavedCurve.SavedKeyFrame>(current.keys.Count);
				int num;
				int num2;
				int num3;
				if (movement.x <= 0f)
				{
					num = 0;
					num2 = current.keys.Count;
					num3 = 1;
				}
				else
				{
					num = current.keys.Count - 1;
					num2 = -1;
					num3 = -1;
				}
				for (int num4 = num; num4 != num2; num4 += num3)
				{
					CurveEditor.SavedCurve.SavedKeyFrame savedKeyFrame = current.keys[num4];
					if (savedKeyFrame.selected != CurveWrapper.SelectionMode.None)
					{
						savedKeyFrame = new CurveEditor.SavedCurve.SavedKeyFrame(savedKeyFrame.key, savedKeyFrame.selected);
						savedKeyFrame.key.time = Mathf.Clamp(savedKeyFrame.key.time + movement.x, base.hRangeMin, base.hRangeMax);
						if (savedKeyFrame.selected == CurveWrapper.SelectionMode.Selected)
						{
							savedKeyFrame.key.value = this.ClampVerticalValue(savedKeyFrame.key.value + movement.y, current.curveId);
						}
						for (int i = list.Count - 1; i >= 0; i--)
						{
							if (Mathf.Abs(list[i].key.time - savedKeyFrame.key.time) < 1E-05f)
							{
								list.RemoveAt(i);
							}
						}
					}
					list.Add(new CurveEditor.SavedCurve.SavedKeyFrame(savedKeyFrame.key, savedKeyFrame.selected));
				}
				list.Sort();
				Keyframe[] array = new Keyframe[list.Count];
				for (int j = 0; j < list.Count; j++)
				{
					CurveEditor.SavedCurve.SavedKeyFrame savedKeyFrame2 = list[j];
					array[j] = savedKeyFrame2.key;
					if (savedKeyFrame2.selected != CurveWrapper.SelectionMode.None)
					{
						CurveSelection curveSelection = new CurveSelection(current.curveId, this, j);
						if (savedKeyFrame2.selected == CurveWrapper.SelectionMode.SemiSelected)
						{
							curveSelection.semiSelected = true;
						}
						this.m_DisplayedSelection.Add(curveSelection);
					}
				}
				CurveWrapper curveFromID = this.GetCurveFromID(current.curveId);
				curveFromID.curve.keys = array;
				curveFromID.changed = true;
			}
			this.UpdateTangentsFromSelection();
		}
コード例 #13
0
 internal void AddSelection(CurveSelection curveSelection)
 {
   this.m_Selection.Add(curveSelection);
   this.lastSelected = curveSelection;
 }
コード例 #14
0
    /// Finds the closest selectable point on the curve.
    /// - Key frames
    /// - if a key frame is selected, searches the tangents
    CurveSelection FindClosest(AnimationCurve curve, Vector2 mousePos, out float outDist)
    {
        float distance = Mathf.Infinity;
        CurveSelection closest = new CurveSelection();

        // Find closest key point
        for (int i=0;i<curve.length;i++)
        {
            Vector2 pos = new Vector2 (curve[i].time, curve[i].value);
            float curDist = Vector2.Distance(pos, mousePos);
            if (curDist < distance)
            {
                closest.index = i;
                closest.type = SelectionType.Key;
                distance = curDist;
            }
        }

        // Find if selected key is close
        CurveSelection activeKey = m_DragKey != null ? m_DragKey : m_SelectedKey;

        if (activeKey != null)
        {
            // Go through tangents and key
            for (int i=0;i<(int)SelectionType.Count;i++)
            {
                Vector2 pos = GetPosition(curve, new CurveSelection(activeKey.index, (SelectionType)i));
                float curDist = Vector2.Distance(pos, mousePos);
                if (curDist < distance)
                {
                    closest.index = activeKey.index;
                    closest.type = (SelectionType)i;
                    distance = curDist;
                }
            }
        }

        outDist = distance;
        if (closest.index != -1)
            return closest;
        else
            return null;
    }
コード例 #15
0
		private CurveSelection AddKeyframeAndSelect(Keyframe key, CurveWrapper cw)
		{
			int num = cw.curve.AddKey(key);
			CurveUtility.SetKeyModeFromContext(cw.curve, num);
			CurveUtility.UpdateTangentsFromModeSurrounding(cw.curve, num);
			CurveSelection result = new CurveSelection(cw.id, this, num);
			cw.selected = CurveWrapper.SelectionMode.Selected;
			cw.changed = true;
			this.activeTime = key.time;
			return result;
		}
コード例 #16
0
    public bool OnGUI(Rect rect)
    {
        bool modified = false;

        GUILayout.BeginArea(rect);

        Color oldColor = GUI.color;
        // Check selection indices out of bounds
        if (m_DragKey != null && (m_DragKey.index < 0 || m_DragKey.index >= animationCurve.length))
            m_DragKey = null;
        if (m_SelectedKey != null && (m_SelectedKey.index < 0 || m_SelectedKey.index >= animationCurve.length) )
            m_SelectedKey = null;

        modified = DisplayActionsGui (rect);

        bool mouseEvent = Event.current.type == EventType.mouseDown || Event.current.type == EventType.mouseDrag | Event.current.type == EventType.mouseUp;

        if (Event.current.type == EventType.repaint)
        {
            DrawGrid(rect);
            DrawCurve(animationCurve);
        }
        else if (Event.current.type == EventType.mouseDown && Event.current.clickCount == 2)
        {
            Keyframe key = new Keyframe(transformedMousePosition.x, transformedMousePosition.y);
            SetKeyTangentMode(ref key, 0, TangentMode.Smooth);
            SetKeyTangentMode(ref key, 1, TangentMode.Smooth);
            int index = animationCurve.AddKey(key);

            UpdateTangentsFromModeSurrounding(animationCurve, index);
            m_DragKey = new CurveSelection (index, SelectionType.Key);
            modified = true;
            Event.current.Use();
        }
        else if ((Event.current.type == EventType.scrollWheel) || (mouseEvent && Event.current.command))
        {
            m_Scale *= (1 - Event.current.delta.y * 0.01F);
            m_Scale.x = Mathf.Clamp(m_Scale.x, 0.02F, 10000.0F);
            m_Scale.y = -m_Scale.x;
            Event.current.Use();
        }
        else if (mouseEvent && Event.current.alt)
        {
            m_Translation += Event.current.delta;
            Event.current.Use();
        }
        else if (Event.current.type == EventType.mouseDown)
        {
            float dist;
            CurveSelection closest = FindClosest(animationCurve, transformedMousePosition, out dist);
            if (dist < 20 / m_Scale.magnitude)
            {
                m_SelectedKey = m_DragKey = closest;
                Vector2 keyPos = GetPosition(animationCurve, m_DragKey);
                m_MouseDownOffset = keyPos - transformedMousePosition;
            }
            else
            {
                m_DragKey = null;
            }
            Event.current.Use();
        }
        else if (Event.current.type == EventType.mouseUp)
        {
            m_SelectedKey = m_DragKey;
            m_DragKey = null;
            Event.current.Use();
        }
        else if (Event.current.type == EventType.mouseDrag && m_DragKey != null)
        {
            Keyframe key = animationCurve[m_DragKey.index];

            Vector2 newPosition = transformedMousePosition + m_MouseDownOffset;
            if (m_DragKey.type == SelectionType.Key)
            {
                key.time = newPosition.x;
                key.value = newPosition.y;
            }
            else if (m_DragKey.type == SelectionType.InTangent)
            {
                Vector2 tangentDirection = newPosition - new Vector2 (key.time, key.value);
                if (tangentDirection.x < -0.0001F)
                    key.inTangent = tangentDirection.y / tangentDirection.x;
                else
                    key.inTangent = Mathf.Infinity;
                SetKeyTangentMode(ref key, 0, TangentMode.Editable);

                if (!GetKeyBroken(key))
                {
                    key.outTangent = key.inTangent;
                    SetKeyTangentMode(ref key, 1, TangentMode.Editable);
                }
            }
            else if (m_DragKey.type == SelectionType.OutTangent)
            {
                Vector2 tangentDirection = newPosition - new Vector2 (key.time, key.value);
                if (tangentDirection.x > 0.0001F)
                    key.outTangent = tangentDirection.y / tangentDirection.x;
                else
                    key.outTangent = Mathf.Infinity;
                SetKeyTangentMode(ref key, 1, TangentMode.Editable);

                if (!GetKeyBroken(key))
                {
                    key.inTangent = key.outTangent;
                    SetKeyTangentMode(ref key, 0, TangentMode.Editable);
                }
            }

            m_DragKey.index = animationCurve.MoveKey(m_DragKey.index, key);

            UpdateTangentsFromModeSurrounding(animationCurve, m_DragKey.index);
            modified = true;

            Event.current.Use();
        }
        else if ((Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Backspace) || (Event.current.type == EventType.ExecuteCommand && Event.current.commandName =="Delete"))
        {
            if (m_SelectedKey != null)
            {
                animationCurve.RemoveKey(m_SelectedKey.index);
                m_SelectedKey.index--;
                modified = true;
                Event.current.Use();
            }
        }
        else if (Event.current.type == EventType.ExecuteCommand && Event.current.commandName == "FrameSelected")
        {
            FrameSelected(rect);
            Event.current.Use();
        }
        GUILayout.EndArea();

        GUI.color = oldColor;

        return modified;
    }
コード例 #17
0
        public override bool Equals(object _other)
        {
            CurveSelection other = (CurveSelection)_other;

            return(other.curveID == curveID && other.key == key && other.type == type);
        }
コード例 #18
0
 private void UpdateCurvesFromPoints(System.Action<CurveEditor.SavedCurve.SavedKeyFrame, CurveEditor.SavedCurve> action)
 {
   List<CurveSelection> curveSelectionList = new List<CurveSelection>();
   using (List<CurveEditor.SavedCurve>.Enumerator enumerator = this.m_CurveBackups.GetEnumerator())
   {
     while (enumerator.MoveNext())
     {
       CurveEditor.SavedCurve current = enumerator.Current;
       List<CurveEditor.SavedCurve.SavedKeyFrame> savedKeyFrameList = new List<CurveEditor.SavedCurve.SavedKeyFrame>(current.keys.Count);
       for (int index1 = 0; index1 != current.keys.Count; ++index1)
       {
         CurveEditor.SavedCurve.SavedKeyFrame savedKeyFrame = current.keys[index1];
         if (savedKeyFrame.selected != CurveWrapper.SelectionMode.None)
         {
           savedKeyFrame = new CurveEditor.SavedCurve.SavedKeyFrame(savedKeyFrame.key, savedKeyFrame.selected);
           action(savedKeyFrame, current);
           for (int index2 = savedKeyFrameList.Count - 1; index2 >= 0; --index2)
           {
             if ((double) Mathf.Abs(savedKeyFrameList[index2].key.time - savedKeyFrame.key.time) < 9.99999974737875E-06)
               savedKeyFrameList.RemoveAt(index2);
           }
         }
         savedKeyFrameList.Add(new CurveEditor.SavedCurve.SavedKeyFrame(savedKeyFrame.key, savedKeyFrame.selected));
       }
       savedKeyFrameList.Sort();
       Keyframe[] keyframeArray = new Keyframe[savedKeyFrameList.Count];
       for (int keyIndex = 0; keyIndex < savedKeyFrameList.Count; ++keyIndex)
       {
         CurveEditor.SavedCurve.SavedKeyFrame savedKeyFrame = savedKeyFrameList[keyIndex];
         keyframeArray[keyIndex] = savedKeyFrame.key;
         if (savedKeyFrame.selected != CurveWrapper.SelectionMode.None)
         {
           CurveSelection curveSelection = new CurveSelection(current.curveId, this, keyIndex);
           if (savedKeyFrame.selected == CurveWrapper.SelectionMode.SemiSelected)
             curveSelection.semiSelected = true;
           curveSelectionList.Add(curveSelection);
         }
       }
       this.selectedCurves = curveSelectionList;
       CurveWrapper curveFromId = this.GetCurveFromID(current.curveId);
       curveFromId.curve.keys = keyframeArray;
       curveFromId.changed = true;
     }
   }
   this.UpdateTangentsFromSelection();
 }
コード例 #19
0
 private void DragTangents()
 {
   Event current1 = Event.current;
   int controlId = GUIUtility.GetControlID(CurveEditor.s_TangentControlIDHash, FocusType.Passive);
   switch (current1.GetTypeForControl(controlId))
   {
     case EventType.MouseDown:
       if (current1.button != 0 || current1.alt)
         break;
       this.m_SelectedTangentPoint = (CurveSelection) null;
       float num = 100f;
       Vector2 mousePosition = Event.current.mousePosition;
       using (List<CurveSelection>.Enumerator enumerator = this.selectedCurves.GetEnumerator())
       {
         while (enumerator.MoveNext())
         {
           CurveSelection current2 = enumerator.Current;
           Keyframe keyframe = current2.keyframe;
           if (CurveUtility.GetKeyTangentMode(keyframe, 0) == TangentMode.Editable)
           {
             CurveSelection selection = new CurveSelection(current2.curveID, this, current2.key, CurveSelection.SelectionType.InTangent);
             float sqrMagnitude = (this.DrawingToViewTransformPoint(this.GetPosition(selection)) - mousePosition).sqrMagnitude;
             if ((double) sqrMagnitude <= (double) num)
             {
               this.m_SelectedTangentPoint = selection;
               num = sqrMagnitude;
             }
           }
           if (CurveUtility.GetKeyTangentMode(keyframe, 1) == TangentMode.Editable)
           {
             CurveSelection selection = new CurveSelection(current2.curveID, this, current2.key, CurveSelection.SelectionType.OutTangent);
             float sqrMagnitude = (this.DrawingToViewTransformPoint(this.GetPosition(selection)) - mousePosition).sqrMagnitude;
             if ((double) sqrMagnitude <= (double) num)
             {
               this.m_SelectedTangentPoint = selection;
               num = sqrMagnitude;
             }
           }
         }
       }
       if (this.m_SelectedTangentPoint == null)
         break;
       GUIUtility.hotControl = controlId;
       current1.Use();
       break;
     case EventType.MouseUp:
       if (GUIUtility.hotControl != controlId)
         break;
       GUIUtility.hotControl = 0;
       current1.Use();
       break;
     case EventType.MouseDrag:
       if (GUIUtility.hotControl != controlId)
         break;
       Vector2 positionInDrawing = this.mousePositionInDrawing;
       CurveSelection selectedTangentPoint = this.m_SelectedTangentPoint;
       Keyframe keyframe1 = selectedTangentPoint.keyframe;
       if (selectedTangentPoint.type == CurveSelection.SelectionType.InTangent)
       {
         Vector2 vector2 = positionInDrawing - new Vector2(keyframe1.time, keyframe1.value);
         keyframe1.inTangent = (double) vector2.x >= -9.99999974737875E-05 ? float.PositiveInfinity : vector2.y / vector2.x;
         CurveUtility.SetKeyTangentMode(ref keyframe1, 0, TangentMode.Editable);
         if (!CurveUtility.GetKeyBroken(keyframe1))
         {
           keyframe1.outTangent = keyframe1.inTangent;
           CurveUtility.SetKeyTangentMode(ref keyframe1, 1, TangentMode.Editable);
         }
       }
       else if (selectedTangentPoint.type == CurveSelection.SelectionType.OutTangent)
       {
         Vector2 vector2 = positionInDrawing - new Vector2(keyframe1.time, keyframe1.value);
         keyframe1.outTangent = (double) vector2.x <= 9.99999974737875E-05 ? float.PositiveInfinity : vector2.y / vector2.x;
         CurveUtility.SetKeyTangentMode(ref keyframe1, 1, TangentMode.Editable);
         if (!CurveUtility.GetKeyBroken(keyframe1))
         {
           keyframe1.inTangent = keyframe1.outTangent;
           CurveUtility.SetKeyTangentMode(ref keyframe1, 0, TangentMode.Editable);
         }
       }
       selectedTangentPoint.key = selectedTangentPoint.curve.MoveKey(selectedTangentPoint.key, keyframe1);
       CurveUtility.UpdateTangentsFromModeSurrounding(selectedTangentPoint.curveWrapper.curve, selectedTangentPoint.key);
       selectedTangentPoint.curveWrapper.changed = true;
       GUI.changed = true;
       Event.current.Use();
       break;
   }
 }
コード例 #20
0
 internal void ClearSelection()
 {
   this.m_Selection.Clear();
   this.lastSelected = (CurveSelection) null;
 }
コード例 #21
0
 internal void RemoveSelection(CurveSelection curveSelection)
 {
   this.m_Selection.Remove(curveSelection);
   this.lastSelected = (CurveSelection) null;
 }
コード例 #22
0
    Vector2 GetPosition(AnimationCurve curve, CurveSelection selection)
    {
        Keyframe key = curve[selection.index];
        Vector2 position = new Vector2 (key.time, key.value);

        if (selection.type == SelectionType.InTangent)
        {
            if (key.inTangent == Mathf.Infinity)
                return position + Vector2.Scale(new Vector2(0.0F, -1.0F), GetTangentScale());
            else
            {
                Vector2 dir = new Vector2(1.0F, key.inTangent);
                dir /= dir.magnitude;
                return position - Vector2.Scale(dir, GetTangentScale ());
            }
        }
        else if (selection.type == SelectionType.OutTangent)
        {
            if (key.outTangent == Mathf.Infinity)
            {
                return position + Vector2.Scale(new Vector2(0.0F, 1.0F), GetTangentScale());
            }
            else
            {
                Vector2 dir = new Vector2(1.0F, key.outTangent);
                dir /= dir.magnitude;
                return position + Vector2.Scale(dir, GetTangentScale());
            }
        }
        else
            return position;
    }
コード例 #23
0
		private Vector2 GetPosition(CurveSelection selection)
		{
			Keyframe keyframe = selection.keyframe;
			Vector2 vector = new Vector2(keyframe.time, keyframe.value);
			float d = 50f;
			if (selection.type == CurveSelection.SelectionType.InTangent)
			{
				Vector2 vector2 = new Vector2(1f, keyframe.inTangent);
				if (keyframe.inTangent == float.PositiveInfinity)
				{
					vector2 = new Vector2(0f, -1f);
				}
				vector2 = base.NormalizeInViewSpace(vector2);
				return vector - vector2 * d;
			}
			if (selection.type == CurveSelection.SelectionType.OutTangent)
			{
				Vector2 vector3 = new Vector2(1f, keyframe.outTangent);
				if (keyframe.outTangent == float.PositiveInfinity)
				{
					vector3 = new Vector2(0f, -1f);
				}
				vector3 = base.NormalizeInViewSpace(vector3);
				return vector + vector3 * d;
			}
			return vector;
		}
コード例 #24
0
		private void DragTangents()
		{
			Event current = Event.current;
			int controlID = GUIUtility.GetControlID(CurveEditor.s_TangentControlIDHash, FocusType.Passive);
			switch (current.GetTypeForControl(controlID))
			{
			case EventType.MouseDown:
				if (current.button == 0 && !current.alt)
				{
					this.m_SelectedTangentPoint = null;
					float num = 64f;
					Vector2 mousePosition = Event.current.mousePosition;
					foreach (CurveSelection current2 in this.m_Selection)
					{
						Keyframe keyframe = current2.keyframe;
						if (CurveUtility.GetKeyTangentMode(keyframe, 0) == TangentMode.Editable)
						{
							CurveSelection curveSelection = new CurveSelection(current2.curveID, this, current2.key, CurveSelection.SelectionType.InTangent);
							float sqrMagnitude = (base.DrawingToViewTransformPoint(this.GetPosition(curveSelection)) - mousePosition).sqrMagnitude;
							if (sqrMagnitude <= num)
							{
								this.m_SelectedTangentPoint = curveSelection;
								num = sqrMagnitude;
							}
						}
						if (CurveUtility.GetKeyTangentMode(keyframe, 1) == TangentMode.Editable)
						{
							CurveSelection curveSelection2 = new CurveSelection(current2.curveID, this, current2.key, CurveSelection.SelectionType.OutTangent);
							float sqrMagnitude2 = (base.DrawingToViewTransformPoint(this.GetPosition(curveSelection2)) - mousePosition).sqrMagnitude;
							if (sqrMagnitude2 <= num)
							{
								this.m_SelectedTangentPoint = curveSelection2;
								num = sqrMagnitude2;
							}
						}
					}
					if (this.m_SelectedTangentPoint != null)
					{
						GUIUtility.hotControl = controlID;
						this.activeTime = this.m_SelectedTangentPoint.keyframe.time;
						current.Use();
					}
				}
				break;
			case EventType.MouseUp:
				if (GUIUtility.hotControl == controlID)
				{
					GUIUtility.hotControl = 0;
					current.Use();
				}
				break;
			case EventType.MouseDrag:
				if (GUIUtility.hotControl == controlID)
				{
					Vector2 mousePositionInDrawing = base.mousePositionInDrawing;
					CurveSelection selectedTangentPoint = this.m_SelectedTangentPoint;
					Keyframe keyframe2 = selectedTangentPoint.keyframe;
					if (selectedTangentPoint.type == CurveSelection.SelectionType.InTangent)
					{
						Vector2 vector = mousePositionInDrawing - new Vector2(keyframe2.time, keyframe2.value);
						if (vector.x < -0.0001f)
						{
							keyframe2.inTangent = vector.y / vector.x;
						}
						else
						{
							keyframe2.inTangent = float.PositiveInfinity;
						}
						CurveUtility.SetKeyTangentMode(ref keyframe2, 0, TangentMode.Editable);
						if (!CurveUtility.GetKeyBroken(keyframe2))
						{
							keyframe2.outTangent = keyframe2.inTangent;
							CurveUtility.SetKeyTangentMode(ref keyframe2, 1, TangentMode.Editable);
						}
					}
					else
					{
						if (selectedTangentPoint.type == CurveSelection.SelectionType.OutTangent)
						{
							Vector2 vector2 = mousePositionInDrawing - new Vector2(keyframe2.time, keyframe2.value);
							if (vector2.x > 0.0001f)
							{
								keyframe2.outTangent = vector2.y / vector2.x;
							}
							else
							{
								keyframe2.outTangent = float.PositiveInfinity;
							}
							CurveUtility.SetKeyTangentMode(ref keyframe2, 1, TangentMode.Editable);
							if (!CurveUtility.GetKeyBroken(keyframe2))
							{
								keyframe2.inTangent = keyframe2.outTangent;
								CurveUtility.SetKeyTangentMode(ref keyframe2, 0, TangentMode.Editable);
							}
						}
					}
					selectedTangentPoint.key = selectedTangentPoint.curve.MoveKey(selectedTangentPoint.key, keyframe2);
					CurveUtility.UpdateTangentsFromModeSurrounding(selectedTangentPoint.curveWrapper.curve, selectedTangentPoint.key);
					selectedTangentPoint.curveWrapper.changed = true;
					Event.current.Use();
				}
				break;
			}
		}
コード例 #25
0
 public static AnimationWindowKeyframe CurveSelectionToAnimationWindowKeyframe(CurveSelection curveSelection, List<AnimationWindowCurve> allCurves)
 {
     foreach (AnimationWindowCurve curve in allCurves)
     {
         if ((curve.binding == curveSelection.curveWrapper.binding) && (curve.m_Keyframes.Count > curveSelection.key))
         {
             return curve.m_Keyframes[curveSelection.key];
         }
     }
     return null;
 }
コード例 #26
0
 private Vector2 GetPosition(CurveSelection selection)
 {
   Keyframe keyframe = selection.keyframe;
   Vector2 vector2_1 = new Vector2(keyframe.time, keyframe.value);
   float num = 50f;
   if (selection.type == CurveSelection.SelectionType.InTangent)
   {
     Vector2 vec = new Vector2(1f, keyframe.inTangent);
     if ((double) keyframe.inTangent == double.PositiveInfinity)
       vec = new Vector2(0.0f, -1f);
     Vector2 vector2_2 = this.NormalizeInViewSpace(vec);
     return vector2_1 - vector2_2 * num;
   }
   if (selection.type != CurveSelection.SelectionType.OutTangent)
     return vector2_1;
   Vector2 vec1 = new Vector2(1f, keyframe.outTangent);
   if ((double) keyframe.outTangent == double.PositiveInfinity)
     vec1 = new Vector2(0.0f, -1f);
   Vector2 vector2_3 = this.NormalizeInViewSpace(vec1);
   return vector2_1 + vector2_3 * num;
 }