public AddCurvesPopupHierarchyGUI(TreeView treeView, AnimationWindowState state, EditorWindow owner) : base(treeView, true)
 {
     this.plusButtonStyle = new GUIStyle("OL Plus");
     this.plusButtonBackgroundStyle = new GUIStyle("Tag MenuItem");
     this.owner = owner;
     this.state = state;
 }
 public AddCurvesPopupHierarchyDataSource(TreeView treeView, AnimationWindowState animationWindowState)
   : base(treeView)
 {
   this.showRootNode = false;
   this.rootIsCollapsable = false;
   this.state = animationWindowState;
 }
Exemple #3
0
 public static void AddSelectedKeyframes(AnimationWindowState state, AnimationKeyTime time)
 {
     foreach (AnimationWindowCurve current in state.activeCurves)
     {
         AnimationWindowUtility.AddKeyframeToCurve(state, current, time);
     }
 }
 public AnimationWindowHierarchyGUI(TreeViewController treeView, AnimationWindowState state) : base(treeView)
 {
     this.k_AnimatePropertyLabel = new GUIContent("Add Property");
     this.m_LightSkinPropertyTextColor = new Color(0.35f, 0.35f, 0.35f);
     this.m_PhantomCurveColor = new Color(0f, 0.6f, 0.6f);
     this.state = state;
 }
Exemple #5
0
 public AddCurvesPopupHierarchyGUI(TreeView treeView, AnimationWindowState state, EditorWindow owner) : base(treeView, true)
 {
     this.plusButtonStyle           = new GUIStyle("OL Plus");
     this.plusButtonBackgroundStyle = new GUIStyle("Tag MenuItem");
     this.owner = owner;
     this.state = state;
 }
Exemple #6
0
 public AddCurvesPopupHierarchyDataSource(TreeView treeView, AnimationWindowState animationWindowState)
     : base(treeView)
 {
     this.showRootNode      = false;
     this.rootIsCollapsable = false;
     this.state             = animationWindowState;
 }
 public static void AddSelectedKeyframes(AnimationWindowState state, AnimationKeyTime time)
 {
     if (state.activeCurves.Count > 0)
     {
         using (List <AnimationWindowCurve> .Enumerator enumerator = state.activeCurves.GetEnumerator())
         {
             while (enumerator.MoveNext())
             {
                 AnimationWindowCurve current = enumerator.Current;
                 AnimationWindowUtility.AddKeyframeToCurve(state, current, time);
             }
         }
     }
     else
     {
         using (List <AnimationWindowCurve> .Enumerator enumerator = state.allCurves.GetEnumerator())
         {
             while (enumerator.MoveNext())
             {
                 AnimationWindowCurve current = enumerator.Current;
                 AnimationWindowUtility.AddKeyframeToCurve(state, current, time);
             }
         }
     }
 }
Exemple #8
0
        internal static void CopyEvents(IList <AnimationEvent> allEvents, bool[] selected, int explicitIndex = -1)
        {
            var copyEvents = new List <AnimationWindowEventClipboard>();

            // If a selection already exists, copy selection instead of clicked index
            if (Array.Exists(selected, s => s))
            {
                for (var i = 0; i < selected.Length; ++i)
                {
                    if (selected[i])
                    {
                        copyEvents.Add(new AnimationWindowEventClipboard(allEvents[i]));
                    }
                }
            }
            // Else, only copy the clicked animation event
            else if (explicitIndex >= 0)
            {
                copyEvents.Add(new AnimationWindowEventClipboard(allEvents[explicitIndex]));
            }
            var data = new AnimationWindowEventsClipboard {
                events = copyEvents.ToArray()
            };

            // Animation keyframes right now do not go through regular clipboard machinery,
            // so when copying Events, make sure Keyframes are cleared from the clipboard, or things
            // get confusing.
            AnimationWindowState.ClearKeyframeClipboard();

            Clipboard.SetCustomValue(data);
        }
Exemple #9
0
        private static void AddKey(AnimationWindowState state, EditorCurveBinding binding, System.Type type, PropertyModification modification)
        {
            GameObject    activeRootGameObject = state.activeRootGameObject;
            AnimationClip activeAnimationClip  = state.activeAnimationClip;

            if ((activeAnimationClip.hideFlags & HideFlags.NotEditable) != HideFlags.None)
            {
                return;
            }
            AnimationWindowCurve curve = new AnimationWindowCurve(activeAnimationClip, binding, type);
            object currentValue        = CurveBindingUtility.GetCurrentValue(activeRootGameObject, binding);

            if (curve.length == 0)
            {
                object outObject = (object)null;
                if (!AnimationRecording.ValueFromPropertyModification(modification, binding, out outObject))
                {
                    outObject = currentValue;
                }
                if (state.frame != 0)
                {
                    AnimationWindowUtility.AddKeyframeToCurve(curve, outObject, type, AnimationKeyTime.Frame(0, activeAnimationClip.frameRate));
                }
            }
            AnimationWindowUtility.AddKeyframeToCurve(curve, currentValue, type, AnimationKeyTime.Frame(state.frame, activeAnimationClip.frameRate));
            state.SaveCurve(curve);
        }
 public AnimationWindowHierarchyGUI(TreeViewController treeView, AnimationWindowState state) : base(treeView)
 {
     this.k_AnimatePropertyLabel       = new GUIContent("Add Property");
     this.m_LightSkinPropertyTextColor = new Color(0.35f, 0.35f, 0.35f);
     this.m_PhantomCurveColor          = new Color(0f, 0.6f, 0.6f);
     this.state = state;
 }
 public static void CreateDefaultCurves(AnimationWindowState state, EditorCurveBinding[] properties)
 {
   AnimationClip activeAnimationClip = state.activeAnimationClip;
   GameObject activeRootGameObject = state.activeRootGameObject;
   properties = RotationCurveInterpolation.ConvertRotationPropertiesToDefaultInterpolation(state.activeAnimationClip, properties);
   foreach (EditorCurveBinding property in properties)
     state.SaveCurve(AnimationWindowUtility.CreateDefaultCurve(activeAnimationClip, activeRootGameObject, property));
 }
 public static object GetCurrentValue(AnimationWindowState state, AnimationWindowCurve curve)
 {
     if (UnityEditor.AnimationMode.InAnimationMode() && (curve.rootGameObject != null))
     {
         return(AnimationWindowUtility.GetCurrentValue(curve.rootGameObject, curve.binding));
     }
     return(curve.Evaluate(state.currentTime - curve.timeOffset));
 }
 public static AnimationWindowKeyframe AddKeyframeToCurve(AnimationWindowState state, AnimationWindowCurve curve, AnimationKeyTime time)
 {
     object currentValue = CurveBindingUtility.GetCurrentValue(state.activeRootGameObject, curve.binding);
     System.Type editorCurveValueType = CurveBindingUtility.GetEditorCurveValueType(state.activeRootGameObject, curve.binding);
     AnimationWindowKeyframe keyframe = AddKeyframeToCurve(curve, currentValue, editorCurveValueType, time);
     state.SaveCurve(curve);
     return keyframe;
 }
 public static object GetCurrentValue(AnimationWindowState state, AnimationWindowCurve curve)
 {
     if (AnimationMode.InAnimationMode() && (curve.rootGameObject != null))
     {
         return AnimationWindowUtility.GetCurrentValue(curve.rootGameObject, curve.binding);
     }
     return curve.Evaluate(state.currentTime - curve.timeOffset);
 }
Exemple #15
0
        public static AnimationWindowKeyframe AddKeyframeToCurve(AnimationWindowState state, AnimationWindowCurve curve, AnimationKeyTime time)
        {
            object currentValue            = AnimationWindowUtility.GetCurrentValue(state.m_RootGameObject, curve.binding);
            Type   editorCurveValueType    = AnimationUtility.GetEditorCurveValueType(state.m_RootGameObject, curve.binding);
            AnimationWindowKeyframe result = AnimationWindowUtility.AddKeyframeToCurve(curve, currentValue, editorCurveValueType, time);

            state.SaveCurve(curve);
            return(result);
        }
Exemple #16
0
        public static AnimationWindowKeyframe AddKeyframeToCurve(AnimationWindowState state, AnimationWindowCurve curve, AnimationKeyTime time)
        {
            object currentValue              = CurveBindingUtility.GetCurrentValue(state.activeRootGameObject, curve.binding);
            Type   editorCurveValueType      = CurveBindingUtility.GetEditorCurveValueType(state.activeRootGameObject, curve.binding);
            AnimationWindowKeyframe keyframe = AddKeyframeToCurve(curve, currentValue, editorCurveValueType, time);

            state.SaveCurve(curve);
            return(keyframe);
        }
 internal static bool ShowAtPosition(Rect buttonRect, AnimationWindowState state)
 {
   if (DateTime.Now.Ticks / 10000L < AddCurvesPopup.s_LastClosedTime + 50L)
     return false;
   Event.current.Use();
   if ((UnityEngine.Object) AddCurvesPopup.s_AddCurvesPopup == (UnityEngine.Object) null)
     AddCurvesPopup.s_AddCurvesPopup = ScriptableObject.CreateInstance<AddCurvesPopup>();
   AddCurvesPopup.s_State = state;
   AddCurvesPopup.s_AddCurvesPopup.Init(buttonRect);
   return true;
 }
        public static void CreateDefaultCurves(AnimationWindowState state, EditorCurveBinding[] properties)
        {
            AnimationClip activeAnimationClip  = state.activeAnimationClip;
            GameObject    activeRootGameObject = state.activeRootGameObject;

            properties = RotationCurveInterpolation.ConvertRotationPropertiesToDefaultInterpolation(state.activeAnimationClip, properties);
            foreach (EditorCurveBinding property in properties)
            {
                state.SaveCurve(AnimationWindowUtility.CreateDefaultCurve(activeAnimationClip, activeRootGameObject, property));
            }
        }
Exemple #19
0
 // Retrieve current value.  If bindings are available and value is animated, use bindings to get value.
 // Otherwise, evaluate AnimationWindowCurve at current time.
 public static object GetCurrentValue(AnimationWindowState state, AnimationWindowCurve curve)
 {
     if (state.previewing && curve.rootGameObject != null)
     {
         return(AnimationWindowUtility.GetCurrentValue(curve.rootGameObject, curve.binding));
     }
     else
     {
         return(curve.Evaluate(state.currentTime));
     }
 }
        public static void AddSelectedKeyframes(AnimationWindowState state, AnimationKeyTime time)
        {
            List <AnimationWindowCurve> list = (state.activeCurves.Count <= 0) ? state.allCurves : state.activeCurves;

            foreach (AnimationWindowCurve current in list)
            {
                if (current.animationIsEditable)
                {
                    AnimationWindowUtility.AddKeyframeToCurve(state, current, AnimationKeyTime.Time(time.time - current.timeOffset, time.frameRate));
                }
            }
        }
		public static void CreateDefaultCurves(AnimationWindowState state, EditorCurveBinding[] properties)
		{
			AnimationClip activeAnimationClip = state.m_ActiveAnimationClip;
			GameObject rootGameObject = state.m_RootGameObject;
			properties = RotationCurveInterpolation.ConvertRotationPropertiesToDefaultInterpolation(state.m_ActiveAnimationClip, properties);
			EditorCurveBinding[] array = properties;
			for (int i = 0; i < array.Length; i++)
			{
				EditorCurveBinding binding = array[i];
				state.SaveCurve(AnimationWindowUtility.CreateDefaultCurve(activeAnimationClip, rootGameObject, binding));
			}
		}
Exemple #22
0
        public static UndoPropertyModification[] Process(AnimationWindowState state, UndoPropertyModification[] modifications)
        {
            GameObject activeRootGameObject = state.activeRootGameObject;

            if ((UnityEngine.Object)activeRootGameObject == (UnityEngine.Object)null)
            {
                return(modifications);
            }
            AnimationClip activeAnimationClip = state.activeAnimationClip;
            Animator      component           = activeRootGameObject.GetComponent <Animator>();

            if (!AnimationRecording.HasAnyRecordableModifications(activeRootGameObject, modifications))
            {
                return(modifications);
            }
            AnimationRecording.ProcessRotationModifications(state, ref modifications);
            List <UndoPropertyModification> propertyModificationList = new List <UndoPropertyModification>();

            for (int index1 = 0; index1 < modifications.Length; ++index1)
            {
                EditorCurveBinding   binding            = new EditorCurveBinding();
                PropertyModification previousValue      = modifications[index1].previousValue;
                System.Type          editorCurveBinding = AnimationUtility.PropertyModificationToEditorCurveBinding(previousValue, activeRootGameObject, out binding);
                if (editorCurveBinding != null && editorCurveBinding != typeof(Animator))
                {
                    if ((UnityEngine.Object)component != (UnityEngine.Object)null && component.isHuman && (binding.type == typeof(Transform) && component.IsBoneTransform(previousValue.target as Transform)))
                    {
                        Debug.LogWarning((object)"Keyframing for humanoid rig is not supported!", (UnityEngine.Object)(previousValue.target as Transform));
                    }
                    else
                    {
                        AnimationMode.AddPropertyModification(binding, previousValue, modifications[index1].keepPrefabOverride);
                        EditorCurveBinding[] editorCurveBindingArray = RotationCurveInterpolation.RemapAnimationBindingForAddKey(binding, activeAnimationClip);
                        if (editorCurveBindingArray != null)
                        {
                            for (int index2 = 0; index2 < editorCurveBindingArray.Length; ++index2)
                            {
                                AnimationRecording.AddKey(state, editorCurveBindingArray[index2], editorCurveBinding, AnimationRecording.FindPropertyModification(activeRootGameObject, modifications, editorCurveBindingArray[index2]));
                            }
                        }
                        else
                        {
                            AnimationRecording.AddKey(state, binding, editorCurveBinding, previousValue);
                        }
                    }
                }
                else
                {
                    propertyModificationList.Add(modifications[index1]);
                }
            }
            return(propertyModificationList.ToArray());
        }
Exemple #23
0
        public static void CreateDefaultCurves(AnimationWindowState state, EditorCurveBinding[] properties)
        {
            AnimationClip activeAnimationClip = state.m_ActiveAnimationClip;
            GameObject    rootGameObject      = state.m_RootGameObject;

            properties = RotationCurveInterpolation.ConvertRotationPropertiesToDefaultInterpolation(state.m_ActiveAnimationClip, properties);
            EditorCurveBinding[] array = properties;
            for (int i = 0; i < array.Length; i++)
            {
                EditorCurveBinding binding = array[i];
                state.SaveCurve(AnimationWindowUtility.CreateDefaultCurve(activeAnimationClip, rootGameObject, binding));
            }
        }
Exemple #24
0
        public static object GetCurrentValue(AnimationWindowState state, AnimationWindowCurve curve)
        {
            object result;

            if (AnimationMode.InAnimationMode() && curve.rootGameObject != null)
            {
                result = AnimationWindowUtility.GetCurrentValue(curve.rootGameObject, curve.binding);
            }
            else
            {
                result = curve.Evaluate(state.currentTime - curve.timeOffset);
            }
            return(result);
        }
Exemple #25
0
 internal static bool ShowAtPosition(Rect buttonRect, AnimationWindowState state)
 {
     if (DateTime.Now.Ticks / 10000L < AddCurvesPopup.s_LastClosedTime + 50L)
     {
         return(false);
     }
     Event.current.Use();
     if ((UnityEngine.Object)AddCurvesPopup.s_AddCurvesPopup == (UnityEngine.Object)null)
     {
         AddCurvesPopup.s_AddCurvesPopup = ScriptableObject.CreateInstance <AddCurvesPopup>();
     }
     AddCurvesPopup.s_State = state;
     AddCurvesPopup.s_AddCurvesPopup.Init(buttonRect);
     return(true);
 }
 private static void CollectRotationModifications(AnimationWindowState state, ref UndoPropertyModification[] modifications, ref Dictionary<object, AnimationRecording.RotationModification> rotationModifications)
 {
   List<UndoPropertyModification> propertyModificationList = new List<UndoPropertyModification>();
   foreach (UndoPropertyModification propertyModification in modifications)
   {
     EditorCurveBinding binding = new EditorCurveBinding();
     PropertyModification previousValue = propertyModification.previousValue;
     AnimationUtility.PropertyModificationToEditorCurveBinding(previousValue, state.activeRootGameObject, out binding);
     if (binding.propertyName.StartsWith("m_LocalRotation"))
     {
       AnimationRecording.RotationModification rotationModification;
       if (!rotationModifications.TryGetValue((object) previousValue.target, out rotationModification))
       {
         rotationModification = new AnimationRecording.RotationModification();
         rotationModifications[(object) previousValue.target] = rotationModification;
       }
       if (binding.propertyName.EndsWith("x"))
         rotationModification.x = propertyModification;
       else if (binding.propertyName.EndsWith("y"))
         rotationModification.y = propertyModification;
       else if (binding.propertyName.EndsWith("z"))
         rotationModification.z = propertyModification;
       else if (binding.propertyName.EndsWith("w"))
         rotationModification.w = propertyModification;
       rotationModification.lastQuatModification = propertyModification;
     }
     else if (previousValue.propertyPath.StartsWith("m_LocalEulerAnglesHint"))
     {
       AnimationRecording.RotationModification rotationModification;
       if (!rotationModifications.TryGetValue((object) previousValue.target, out rotationModification))
       {
         rotationModification = new AnimationRecording.RotationModification();
         rotationModifications[(object) previousValue.target] = rotationModification;
       }
       if (previousValue.propertyPath.EndsWith("x"))
         rotationModification.eulerX = propertyModification;
       else if (previousValue.propertyPath.EndsWith("y"))
         rotationModification.eulerY = propertyModification;
       else if (previousValue.propertyPath.EndsWith("z"))
         rotationModification.eulerZ = propertyModification;
     }
     else
       propertyModificationList.Add(propertyModification);
   }
   if (propertyModificationList.Count <= 0)
     return;
   modifications = propertyModificationList.ToArray();
 }
Exemple #27
0
 internal static bool ShowAtPosition(Rect buttonRect, AnimationWindowState state)
 {
     long num = DateTime.Now.Ticks / 0x2710L;
     if (num < (s_LastClosedTime + 50L))
     {
         return false;
     }
     Event.current.Use();
     if (s_AddCurvesPopup == null)
     {
         s_AddCurvesPopup = ScriptableObject.CreateInstance<AddCurvesPopup>();
     }
     s_State = state;
     s_AddCurvesPopup.Init(buttonRect);
     return true;
 }
        public static void RemoveKeyframes(AnimationWindowState state, AnimationWindowCurve[] curves, AnimationKeyTime time)
        {
            string undoLabel = "Remove Key";

            state.SaveKeySelection(undoLabel);
            for (int i = 0; i < curves.Length; i++)
            {
                AnimationWindowCurve animationWindowCurve = curves[i];
                if (animationWindowCurve.animationIsEditable)
                {
                    AnimationKeyTime time2 = AnimationKeyTime.Time(time.time - animationWindowCurve.timeOffset, time.frameRate);
                    animationWindowCurve.RemoveKeyframe(time2);
                    state.SaveCurve(animationWindowCurve, undoLabel);
                }
            }
        }
Exemple #29
0
        public static UndoPropertyModification[] Process(AnimationWindowState state, UndoPropertyModification[] modifications)
        {
            GameObject    activeRootGameObject = state.activeRootGameObject;
            AnimationClip activeAnimationClip  = state.activeAnimationClip;
            Animator      component            = activeRootGameObject.GetComponent <Animator>();

            if (!AnimationRecording.HasAnyRecordableModifications(activeRootGameObject, modifications))
            {
                return(modifications);
            }
            List <UndoPropertyModification> list = new List <UndoPropertyModification>();

            for (int i = 0; i < modifications.Length; i++)
            {
                EditorCurveBinding   binding       = default(EditorCurveBinding);
                PropertyModification previousValue = modifications[i].previousValue;
                Type type = AnimationUtility.PropertyModificationToEditorCurveBinding(previousValue, activeRootGameObject, out binding);
                if (type != null && type != typeof(Animator))
                {
                    if (component != null && component.isHuman && binding.type == typeof(Transform) && component.IsBoneTransform(previousValue.target as Transform))
                    {
                        Debug.LogWarning("Keyframing for humanoid rig is not supported!", previousValue.target as Transform);
                    }
                    else
                    {
                        AnimationMode.AddPropertyModification(binding, previousValue, modifications[i].keepPrefabOverride);
                        EditorCurveBinding[] array = RotationCurveInterpolation.RemapAnimationBindingForAddKey(binding, activeAnimationClip);
                        if (array != null)
                        {
                            for (int j = 0; j < array.Length; j++)
                            {
                                AnimationRecording.AddKey(state, array[j], type, AnimationRecording.FindPropertyModification(activeRootGameObject, modifications, array[j]));
                            }
                        }
                        else
                        {
                            AnimationRecording.AddKey(state, binding, type, previousValue);
                        }
                    }
                }
                else
                {
                    list.Add(modifications[i]);
                }
            }
            return(list.ToArray());
        }
Exemple #30
0
        internal static bool ShowAtPosition(Rect buttonRect, AnimationWindowState state)
        {
            long num = DateTime.Now.Ticks / 10000L;

            if (num >= AddCurvesPopup.s_LastClosedTime + 50L)
            {
                Event.current.Use();
                if (AddCurvesPopup.s_AddCurvesPopup == null)
                {
                    AddCurvesPopup.s_AddCurvesPopup = ScriptableObject.CreateInstance <AddCurvesPopup>();
                }
                AddCurvesPopup.s_State = state;
                AddCurvesPopup.s_AddCurvesPopup.Init(buttonRect);
                return(true);
            }
            return(false);
        }
Exemple #31
0
 public static void AddSelectedKeyframes(AnimationWindowState state, AnimationKeyTime time)
 {
     if (state.activeCurves.Count > 0)
     {
         foreach (AnimationWindowCurve curve in state.activeCurves)
         {
             AddKeyframeToCurve(state, curve, time);
         }
     }
     else
     {
         foreach (AnimationWindowCurve curve2 in state.allCurves)
         {
             AddKeyframeToCurve(state, curve2, time);
         }
     }
 }
 public static UndoPropertyModification[] Process(AnimationWindowState state, UndoPropertyModification[] modifications)
 {
     GameObject activeRootGameObject = state.activeRootGameObject;
     AnimationClip activeAnimationClip = state.activeAnimationClip;
     Animator component = activeRootGameObject.GetComponent<Animator>();
     if (!HasAnyRecordableModifications(activeRootGameObject, modifications))
     {
         return modifications;
     }
     List<UndoPropertyModification> list = new List<UndoPropertyModification>();
     for (int i = 0; i < modifications.Length; i++)
     {
         EditorCurveBinding binding = new EditorCurveBinding();
         PropertyModification previousValue = modifications[i].previousValue;
         System.Type type = AnimationUtility.PropertyModificationToEditorCurveBinding(previousValue, activeRootGameObject, out binding);
         if ((type != null) && (type != typeof(Animator)))
         {
             if (((component != null) && component.isHuman) && ((binding.type == typeof(Transform)) && component.IsBoneTransform(previousValue.target as Transform)))
             {
                 Debug.LogWarning("Keyframing for humanoid rig is not supported!", previousValue.target as Transform);
             }
             else
             {
                 AnimationMode.AddPropertyModification(binding, previousValue, modifications[i].keepPrefabOverride);
                 EditorCurveBinding[] bindingArray = RotationCurveInterpolation.RemapAnimationBindingForAddKey(binding, activeAnimationClip);
                 if (bindingArray != null)
                 {
                     for (int j = 0; j < bindingArray.Length; j++)
                     {
                         AddKey(state, bindingArray[j], type, FindPropertyModification(activeRootGameObject, modifications, bindingArray[j]));
                     }
                 }
                 else
                 {
                     AddKey(state, binding, type, previousValue);
                 }
             }
         }
         else
         {
             list.Add(modifications[i]);
         }
     }
     return list.ToArray();
 }
		public static UndoPropertyModification[] Process(AnimationWindowState state, UndoPropertyModification[] modifications)
		{
			GameObject rootGameObject = state.m_RootGameObject;
			AnimationClip activeAnimationClip = state.m_ActiveAnimationClip;
			Animator component = rootGameObject.GetComponent<Animator>();
			if (!AnimationRecording.HasAnyRecordableModifications(rootGameObject, modifications))
			{
				return modifications;
			}
			List<UndoPropertyModification> list = new List<UndoPropertyModification>();
			for (int i = 0; i < modifications.Length; i++)
			{
				EditorCurveBinding binding = default(EditorCurveBinding);
				PropertyModification propertyModification = modifications[i].propertyModification;
				Type type = AnimationUtility.PropertyModificationToEditorCurveBinding(propertyModification, rootGameObject, out binding);
				if (type != null)
				{
					if (component != null && component.isHuman && binding.type == typeof(Transform) && component.IsBoneTransform(propertyModification.target as Transform))
					{
						Debug.LogWarning("Keyframing for humanoid rig is not supported!", propertyModification.target as Transform);
					}
					else
					{
						AnimationMode.AddPropertyModification(binding, propertyModification, modifications[i].keepPrefabOverride);
						EditorCurveBinding[] array = RotationCurveInterpolation.RemapAnimationBindingForAddKey(binding, activeAnimationClip);
						if (array != null)
						{
							for (int j = 0; j < array.Length; j++)
							{
								AnimationRecording.AddKey(state, array[j], type, AnimationRecording.FindPropertyModification(rootGameObject, modifications, array[j]));
							}
						}
						else
						{
							AnimationRecording.AddKey(state, binding, type, propertyModification);
						}
					}
				}
				else
				{
					list.Add(modifications[i]);
				}
			}
			return list.ToArray();
		}
        public static void AddKeyframes(AnimationWindowState state, AnimationWindowCurve[] curves, AnimationKeyTime time)
        {
            string undoLabel = "Add Key";

            state.SaveKeySelection(undoLabel);
            state.ClearKeySelections();
            foreach (AnimationWindowCurve curve in curves)
            {
                if (curve.animationIsEditable)
                {
                    AnimationKeyTime        time2        = AnimationKeyTime.Time(time.time - curve.timeOffset, time.frameRate);
                    object                  currentValue = CurveBindingUtility.GetCurrentValue(state, curve);
                    AnimationWindowKeyframe keyframe     = AddKeyframeToCurve(curve, currentValue, curve.valueType, time2);
                    state.SaveCurve(curve, undoLabel);
                    state.SelectKey(keyframe);
                }
            }
        }
        private static void AddKey(AnimationWindowState state, EditorCurveBinding binding, Type type, PropertyModification modification)
        {
            GameObject           rootGameObject       = state.m_RootGameObject;
            AnimationClip        activeAnimationClip  = state.m_ActiveAnimationClip;
            AnimationWindowCurve animationWindowCurve = new AnimationWindowCurve(activeAnimationClip, binding, type);
            object currentValue = AnimationWindowUtility.GetCurrentValue(rootGameObject, binding);
            object value        = null;

            if (animationWindowCurve.length == 0 && state.m_Frame != 0)
            {
                if (!AnimationRecording.ValueFromPropertyModification(modification, binding, out value))
                {
                    value = currentValue;
                }
                AnimationWindowUtility.AddKeyframeToCurve(animationWindowCurve, value, type, AnimationKeyTime.Frame(0, activeAnimationClip.frameRate));
            }
            AnimationWindowUtility.AddKeyframeToCurve(animationWindowCurve, currentValue, type, AnimationKeyTime.Frame(state.m_Frame, activeAnimationClip.frameRate));
            state.SaveCurve(animationWindowCurve);
        }
Exemple #36
0
        public static void AddKeyframes(AnimationWindowState state, AnimationWindowCurve[] curves, AnimationKeyTime time)
        {
            string undoLabel = "Add Key";

            state.SaveKeySelection(undoLabel);
            state.ClearKeySelections();
            for (int i = 0; i < curves.Length; i++)
            {
                AnimationWindowCurve animationWindowCurve = curves[i];
                if (animationWindowCurve.animationIsEditable)
                {
                    AnimationKeyTime        time2        = AnimationKeyTime.Time(time.time - animationWindowCurve.timeOffset, time.frameRate);
                    object                  currentValue = CurveBindingUtility.GetCurrentValue(state, animationWindowCurve);
                    AnimationWindowKeyframe keyframe     = AnimationWindowUtility.AddKeyframeToCurve(animationWindowCurve, currentValue, animationWindowCurve.valueType, time2);
                    state.SaveCurve(animationWindowCurve, undoLabel);
                    state.SelectKey(keyframe);
                }
            }
        }
Exemple #37
0
        private static void AddRotationKey(AnimationWindowState state, EditorCurveBinding binding, System.Type type, Vector3 previousEulerAngles, Vector3 currentEulerAngles)
        {
            AnimationClip activeAnimationClip = state.activeAnimationClip;

            if ((activeAnimationClip.hideFlags & HideFlags.NotEditable) != HideFlags.None)
            {
                return;
            }
            EditorCurveBinding[] editorCurveBindingArray = RotationCurveInterpolation.RemapAnimationBindingForRotationAddKey(binding, activeAnimationClip);
            for (int index = 0; index < 3; ++index)
            {
                AnimationWindowCurve curve = new AnimationWindowCurve(activeAnimationClip, editorCurveBindingArray[index], type);
                if (curve.length == 0 && state.frame != 0)
                {
                    AnimationWindowUtility.AddKeyframeToCurve(curve, (object)previousEulerAngles[index], type, AnimationKeyTime.Frame(0, activeAnimationClip.frameRate));
                }
                AnimationWindowUtility.AddKeyframeToCurve(curve, (object)currentEulerAngles[index], type, AnimationKeyTime.Frame(state.frame, activeAnimationClip.frameRate));
                state.SaveCurve(curve);
            }
        }
        internal static bool ShowAtPosition(Rect buttonRect, AnimationWindowState state, OnNewCurveAdded newCurveCallback)
        {
            // We could not use realtimeSinceStartUp since it is set to 0 when entering/exitting playmode, we assume an increasing time when comparing time.
            long nowMilliSeconds = System.DateTime.Now.Ticks / System.TimeSpan.TicksPerMillisecond;
            bool justClosed      = nowMilliSeconds < s_LastClosedTime + 50;

            if (!justClosed)
            {
                Event.current.Use();
                if (s_AddCurvesPopup == null)
                {
                    s_AddCurvesPopup = ScriptableObject.CreateInstance <AddCurvesPopup>();
                }

                NewCurveAddedCallback = newCurveCallback;
                s_State = state;
                s_AddCurvesPopup.Init(buttonRect);
                return(true);
            }
            return(false);
        }
 private static void AddKey(AnimationWindowState state, EditorCurveBinding binding, System.Type type, PropertyModification modification)
 {
     GameObject activeRootGameObject = state.activeRootGameObject;
     AnimationClip activeAnimationClip = state.activeAnimationClip;
     AnimationWindowCurve curve = new AnimationWindowCurve(activeAnimationClip, binding, type);
     object currentValue = CurveBindingUtility.GetCurrentValue(activeRootGameObject, binding);
     if (curve.length == 0)
     {
         object outObject = null;
         if (!ValueFromPropertyModification(modification, binding, out outObject))
         {
             outObject = currentValue;
         }
         if (state.frame != 0)
         {
             AnimationWindowUtility.AddKeyframeToCurve(curve, outObject, type, AnimationKeyTime.Frame(0, activeAnimationClip.frameRate));
         }
     }
     AnimationWindowUtility.AddKeyframeToCurve(curve, currentValue, type, AnimationKeyTime.Frame(state.frame, activeAnimationClip.frameRate));
     state.SaveCurve(curve);
 }
Exemple #40
0
        internal static bool ShowAtPosition(Rect buttonRect, AnimationWindowState state, AddCurvesPopup.OnNewCurveAdded newCurveCallback)
        {
            long num = DateTime.Now.Ticks / 10000L;
            bool result;

            if (num >= AddCurvesPopup.s_LastClosedTime + 50L)
            {
                Event.current.Use();
                if (AddCurvesPopup.s_AddCurvesPopup == null)
                {
                    AddCurvesPopup.s_AddCurvesPopup = ScriptableObject.CreateInstance <AddCurvesPopup>();
                }
                AddCurvesPopup.NewCurveAddedCallback = newCurveCallback;
                AddCurvesPopup.s_State = state;
                AddCurvesPopup.s_AddCurvesPopup.Init(buttonRect);
                result = true;
            }
            else
            {
                result = false;
            }
            return(result);
        }
 public static void AddSelectedKeyframes(AnimationWindowState state, AnimationKeyTime time)
 {
     if (state.activeCurves.Count > 0)
     {
         foreach (AnimationWindowCurve curve in state.activeCurves)
         {
             AddKeyframeToCurve(state, curve, time);
         }
     }
     else
     {
         foreach (AnimationWindowCurve curve2 in state.allCurves)
         {
             AddKeyframeToCurve(state, curve2, time);
         }
     }
 }
		public AddCurvesPopupHierarchyGUI(TreeView treeView, AnimationWindowState state, EditorWindow owner) : base(treeView, true)
		{
			this.owner = owner;
			this.state = state;
		}
 public AddCurvesPopupHierarchy(AnimationWindowState state)
 {
     this.state = state;
 }
		public static void AddSelectedKeyframes(AnimationWindowState state, AnimationKeyTime time)
		{
			foreach (AnimationWindowCurve current in state.activeCurves)
			{
				AnimationWindowUtility.AddKeyframeToCurve(state, current, time);
			}
		}
        public void EventLineGUI(Rect rect, AnimationWindowState state)
        {
            if (state.selectedItem != null)
            {
                AnimationClip animationClip = state.selectedItem.animationClip;
                GameObject rootGameObject = state.selectedItem.rootGameObject;
                GUI.BeginGroup(rect);
                Color color = GUI.color;
                Rect rect2 = new Rect(0f, 0f, rect.width, rect.height);
                float time = Mathf.Max((float) (((float) Mathf.RoundToInt(state.PixelToTime(Event.current.mousePosition.x, rect) * state.frameRate)) / state.frameRate), (float) 0f);
                if (animationClip != null)
                {
                    int num8;
                    float num9;
                    float num10;
                    AnimationEvent[] animationEvents = AnimationUtility.GetAnimationEvents(animationClip);
                    Texture image = EditorGUIUtility.IconContent("Animation.EventMarker").image;
                    Rect[] hitPositions = new Rect[animationEvents.Length];
                    Rect[] positions = new Rect[animationEvents.Length];
                    int num2 = 1;
                    int num3 = 0;
                    for (int i = 0; i < animationEvents.Length; i++)
                    {
                        AnimationEvent event2 = animationEvents[i];
                        if (num3 == 0)
                        {
                            num2 = 1;
                            while (((i + num2) < animationEvents.Length) && (animationEvents[i + num2].time == event2.time))
                            {
                                num2++;
                            }
                            num3 = num2;
                        }
                        num3--;
                        float num5 = Mathf.Floor(state.FrameToPixel(event2.time * animationClip.frameRate, rect));
                        int num6 = 0;
                        if (num2 > 1)
                        {
                            float num7 = Mathf.Min((int) ((num2 - 1) * (image.width - 1)), (int) (((int) state.FrameDeltaToPixel(rect)) - (image.width * 2)));
                            num6 = Mathf.FloorToInt(Mathf.Max((float) 0f, (float) (num7 - ((image.width - 1) * num3))));
                        }
                        Rect rect3 = new Rect((num5 + num6) - (image.width / 2), ((rect.height - 10f) * ((num3 - num2) + 1)) / ((float) Mathf.Max(1, num2 - 1)), (float) image.width, (float) image.height);
                        hitPositions[i] = rect3;
                        positions[i] = rect3;
                    }
                    if (this.m_DirtyTooltip)
                    {
                        if ((this.m_HoverEvent >= 0) && (this.m_HoverEvent < hitPositions.Length))
                        {
                            this.m_InstantTooltipText = AnimationWindowEventInspector.FormatEvent(rootGameObject, animationEvents[this.m_HoverEvent]);
                            this.m_InstantTooltipPoint = new Vector2(((hitPositions[this.m_HoverEvent].xMin + ((int) (hitPositions[this.m_HoverEvent].width / 2f))) + rect.x) - 30f, rect.yMax);
                        }
                        this.m_DirtyTooltip = false;
                    }
                    if ((this.m_EventsSelected == null) || (this.m_EventsSelected.Length != animationEvents.Length))
                    {
                        this.m_EventsSelected = new bool[animationEvents.Length];
                    }
                    Vector2 zero = Vector2.zero;
                    switch (EditorGUIExt.MultiSelection(rect, positions, new GUIContent(image), hitPositions, ref this.m_EventsSelected, null, out num8, out zero, out num9, out num10, GUIStyle.none))
                    {
                        case HighLevelEvent.DoubleClick:
                            if (num8 == -1)
                            {
                                this.EventLineContextMenuAdd(new EventLineContextMenuObject(rootGameObject, animationClip, time, -1));
                                break;
                            }
                            Selection.activeObject = AnimationWindowEvent.Edit(rootGameObject, animationClip, num8);
                            break;

                        case HighLevelEvent.ContextClick:
                        {
                            GenericMenu menu = new GenericMenu();
                            EventLineContextMenuObject userData = new EventLineContextMenuObject(rootGameObject, animationClip, animationEvents[num8].time, num8);
                            menu.AddItem(new GUIContent("Edit Animation Event"), false, new GenericMenu.MenuFunction2(this.EventLineContextMenuEdit), userData);
                            menu.AddItem(new GUIContent("Add Animation Event"), false, new GenericMenu.MenuFunction2(this.EventLineContextMenuAdd), userData);
                            menu.AddItem(new GUIContent("Delete Animation Event"), false, new GenericMenu.MenuFunction2(this.EventLineContextMenuDelete), userData);
                            menu.ShowAsContext();
                            this.m_InstantTooltipText = null;
                            this.m_DirtyTooltip = true;
                            state.Repaint();
                            break;
                        }
                        case HighLevelEvent.BeginDrag:
                            this.m_EventsAtMouseDown = animationEvents;
                            this.m_EventTimes = new float[animationEvents.Length];
                            for (int j = 0; j < animationEvents.Length; j++)
                            {
                                this.m_EventTimes[j] = animationEvents[j].time;
                            }
                            break;

                        case HighLevelEvent.Drag:
                        {
                            for (int k = animationEvents.Length - 1; k >= 0; k--)
                            {
                                if (this.m_EventsSelected[k])
                                {
                                    AnimationEvent event6 = this.m_EventsAtMouseDown[k];
                                    event6.time = this.m_EventTimes[k] + (zero.x * state.PixelDeltaToTime(rect));
                                    event6.time = Mathf.Max(0f, event6.time);
                                    event6.time = ((float) Mathf.RoundToInt(event6.time * animationClip.frameRate)) / animationClip.frameRate;
                                }
                            }
                            int[] items = new int[this.m_EventsSelected.Length];
                            for (int m = 0; m < items.Length; m++)
                            {
                                items[m] = m;
                            }
                            Array.Sort(this.m_EventsAtMouseDown, items, new EventComparer());
                            bool[] flagArray = (bool[]) this.m_EventsSelected.Clone();
                            float[] numArray2 = (float[]) this.m_EventTimes.Clone();
                            for (int n = 0; n < items.Length; n++)
                            {
                                this.m_EventsSelected[n] = flagArray[items[n]];
                                this.m_EventTimes[n] = numArray2[items[n]];
                            }
                            Undo.RegisterCompleteObjectUndo(animationClip, "Move Event");
                            AnimationUtility.SetAnimationEvents(animationClip, this.m_EventsAtMouseDown);
                            this.m_DirtyTooltip = true;
                            break;
                        }
                        case HighLevelEvent.Delete:
                            this.DeleteEvents(animationClip, this.m_EventsSelected);
                            break;

                        case HighLevelEvent.SelectionChanged:
                            state.ClearKeySelections();
                            if (num8 != -1)
                            {
                                Selection.activeObject = AnimationWindowEvent.Edit(rootGameObject, animationClip, num8);
                            }
                            break;
                    }
                    this.CheckRectsOnMouseMove(rect, animationEvents, hitPositions);
                }
                if ((Event.current.type == EventType.ContextClick) && rect2.Contains(Event.current.mousePosition))
                {
                    Event.current.Use();
                    GenericMenu menu2 = new GenericMenu();
                    menu2.AddItem(new GUIContent("Add Animation Event"), false, new GenericMenu.MenuFunction2(this.EventLineContextMenuAdd), new EventLineContextMenuObject(rootGameObject, animationClip, time, -1));
                    menu2.ShowAsContext();
                }
                GUI.color = color;
                GUI.EndGroup();
            }
        }
 private static void ProcessRotationModifications(AnimationWindowState state, ref UndoPropertyModification[] modifications)
 {
   Dictionary<object, AnimationRecording.RotationModification> rotationModifications = new Dictionary<object, AnimationRecording.RotationModification>();
   AnimationRecording.CollectRotationModifications(state, ref modifications, ref rotationModifications);
   using (Dictionary<object, AnimationRecording.RotationModification>.Enumerator enumerator = rotationModifications.GetEnumerator())
   {
     while (enumerator.MoveNext())
     {
       AnimationRecording.RotationModification rotationModification = enumerator.Current.Value;
       EditorCurveBinding binding = new EditorCurveBinding();
       System.Type editorCurveBinding = AnimationUtility.PropertyModificationToEditorCurveBinding(rotationModification.lastQuatModification.currentValue, state.activeRootGameObject, out binding);
       Quaternion localRotation1 = state.activeRootGameObject.transform.localRotation;
       Quaternion localRotation2 = state.activeRootGameObject.transform.localRotation;
       object outObject1;
       if (AnimationRecording.ValueFromPropertyModification(rotationModification.x.previousValue, binding, out outObject1))
         localRotation1.x = (float) outObject1;
       object outObject2;
       if (AnimationRecording.ValueFromPropertyModification(rotationModification.y.previousValue, binding, out outObject2))
         localRotation1.y = (float) outObject2;
       object outObject3;
       if (AnimationRecording.ValueFromPropertyModification(rotationModification.z.previousValue, binding, out outObject3))
         localRotation1.z = (float) outObject3;
       object outObject4;
       if (AnimationRecording.ValueFromPropertyModification(rotationModification.w.previousValue, binding, out outObject4))
         localRotation1.w = (float) outObject4;
       if (AnimationRecording.ValueFromPropertyModification(rotationModification.x.currentValue, binding, out outObject1))
         localRotation2.x = (float) outObject1;
       if (AnimationRecording.ValueFromPropertyModification(rotationModification.y.currentValue, binding, out outObject2))
         localRotation2.y = (float) outObject2;
       if (AnimationRecording.ValueFromPropertyModification(rotationModification.z.currentValue, binding, out outObject3))
         localRotation2.z = (float) outObject3;
       if (AnimationRecording.ValueFromPropertyModification(rotationModification.w.currentValue, binding, out outObject4))
         localRotation2.w = (float) outObject4;
       Vector3 eulerAngles1 = localRotation1.eulerAngles;
       Vector3 eulerAngles2 = localRotation2.eulerAngles;
       object outObject5;
       if (AnimationRecording.ValueFromPropertyModification(rotationModification.eulerX.previousValue, binding, out outObject5))
         eulerAngles1.x = (float) outObject5;
       object outObject6;
       if (AnimationRecording.ValueFromPropertyModification(rotationModification.eulerY.previousValue, binding, out outObject6))
         eulerAngles1.y = (float) outObject6;
       object outObject7;
       if (AnimationRecording.ValueFromPropertyModification(rotationModification.eulerZ.previousValue, binding, out outObject7))
         eulerAngles1.z = (float) outObject7;
       if (AnimationRecording.ValueFromPropertyModification(rotationModification.eulerX.currentValue, binding, out outObject5))
         eulerAngles2.x = (float) outObject5;
       if (AnimationRecording.ValueFromPropertyModification(rotationModification.eulerY.currentValue, binding, out outObject6))
         eulerAngles2.y = (float) outObject6;
       if (AnimationRecording.ValueFromPropertyModification(rotationModification.eulerZ.currentValue, binding, out outObject7))
         eulerAngles2.z = (float) outObject7;
       AnimationRecording.AddRotationKey(state, binding, editorCurveBinding, eulerAngles1, eulerAngles2);
     }
   }
 }
 public void OnEnable()
 {
   this.hideFlags = HideFlags.HideAndDontSave;
   AnimEditor.s_AnimationWindows.Add(this);
   if ((UnityEngine.Object) this.m_State == (UnityEngine.Object) null)
   {
     this.m_State = ScriptableObject.CreateInstance(typeof (AnimationWindowState)) as AnimationWindowState;
     this.m_State.hideFlags = HideFlags.HideAndDontSave;
     this.m_State.animEditor = this;
     this.InitializeHorizontalSplitter();
     this.InitializeClipSelection();
     this.InitializeDopeSheet();
     this.InitializeEvents();
     this.InitializeCurveEditor();
   }
   this.InitializeNonserializedValues();
   this.m_State.timeArea = !this.m_State.showCurveEditor ? (TimeArea) this.m_DopeSheet : (TimeArea) this.m_CurveEditor;
   this.m_DopeSheet.state = this.m_State;
   this.m_ClipPopup.state = this.m_State;
   this.m_State.onClipSelectionChanged += new System.Action(this.OnClipSelectionChange);
   this.m_State.OnSelectionChange();
   this.m_CurveEditor.curvesUpdated += new CurveEditor.CallbackFunction(this.SaveChangedCurvesFromCurveEditor);
 }
 private static void AddRotationKey(AnimationWindowState state, EditorCurveBinding binding, System.Type type, Vector3 previousEulerAngles, Vector3 currentEulerAngles)
 {
   AnimationClip activeAnimationClip = state.activeAnimationClip;
   if ((activeAnimationClip.hideFlags & HideFlags.NotEditable) != HideFlags.None)
     return;
   EditorCurveBinding[] editorCurveBindingArray = RotationCurveInterpolation.RemapAnimationBindingForRotationAddKey(binding, activeAnimationClip);
   for (int index = 0; index < 3; ++index)
   {
     AnimationWindowCurve curve = new AnimationWindowCurve(activeAnimationClip, editorCurveBindingArray[index], type);
     if (curve.length == 0 && state.frame != 0)
       AnimationWindowUtility.AddKeyframeToCurve(curve, (object) previousEulerAngles[index], type, AnimationKeyTime.Frame(0, activeAnimationClip.frameRate));
     AnimationWindowUtility.AddKeyframeToCurve(curve, (object) currentEulerAngles[index], type, AnimationKeyTime.Frame(state.frame, activeAnimationClip.frameRate));
     state.SaveCurve(curve);
   }
 }
 public void OnGUI(AnimationWindowState state, AnimationWindowKeyframe keyframe)
 {
   if (keyframe.isPPtrCurve)
     return;
   this.backgroundRect = this.position;
   this.backgroundRect.x = state.TimeToPixel(keyframe.time) + this.position.x - (float) (DopeSheetEditor.DopeSheetPopup.s_width / 2);
   this.backgroundRect.y += 16f;
   this.backgroundRect.width = (float) DopeSheetEditor.DopeSheetPopup.s_width;
   this.backgroundRect.height = (float) DopeSheetEditor.DopeSheetPopup.s_height;
   Rect backgroundRect1 = this.backgroundRect;
   backgroundRect1.height = 16f;
   Rect backgroundRect2 = this.backgroundRect;
   backgroundRect2.y += 16f;
   backgroundRect2.height = (float) DopeSheetEditor.DopeSheetPopup.s_width;
   GUI.Box(this.backgroundRect, string.Empty);
   GUI.Box(backgroundRect2, (Texture) AssetPreview.GetAssetPreview((UnityEngine.Object) keyframe.value));
   EditorGUI.BeginChangeCheck();
   UnityEngine.Object @object = EditorGUI.ObjectField(backgroundRect1, (UnityEngine.Object) keyframe.value, keyframe.curve.m_ValueType, false);
   if (!EditorGUI.EndChangeCheck())
     return;
   keyframe.value = (object) @object;
   state.SaveCurve(keyframe.curve);
 }
Exemple #50
0
 public AnimationWindowHierarchyGUI(TreeView treeView, AnimationWindowState state) : base(treeView)
 {
     this.state = state;
 }
 public AddCurvesPopupHierarchy(AnimationWindowState state)
 {
   this.state = state;
 }
		public DopeSheetEditor(AnimationWindowState state, EditorWindow owner) : base(false)
		{
			this.state = state;
			this.m_Owner = owner;
			this.m_DefaultDopeKeyIcon = EditorGUIUtility.LoadIcon("blendKey");
			this.m_KeyframeClipboard = new List<AnimationWindowKeyframe>();
			base.hSlider = true;
			base.vSlider = false;
			base.vRangeLocked = true;
			base.hRangeMin = 0f;
			base.margin = 40f;
			base.scaleWithWindow = true;
			base.ignoreScrollWheelUntilClicked = false;
			base.hTicks.SetTickModulosForFrameRate(state.frameRate);
		}
		public static AnimationWindowKeyframe AddKeyframeToCurve(AnimationWindowState state, AnimationWindowCurve curve, AnimationKeyTime time)
		{
			object currentValue = AnimationWindowUtility.GetCurrentValue(state.m_RootGameObject, curve.binding);
			Type editorCurveValueType = AnimationUtility.GetEditorCurveValueType(state.m_RootGameObject, curve.binding);
			AnimationWindowKeyframe result = AnimationWindowUtility.AddKeyframeToCurve(curve, currentValue, editorCurveValueType, time);
			state.SaveCurve(curve);
			return result;
		}
		public void AddEvent(AnimationWindowState state)
		{
			float time = (float)state.m_Frame / state.frameRate;
			int index = AnimationEventPopup.Create(state.m_RootGameObject, state.m_ActiveAnimationClip, time, this.m_Owner);
			this.Select(state.m_ActiveAnimationClip, index);
		}
 public AnimationWindowHierarchyGUI(TreeViewController treeView, AnimationWindowState state)
     : base(treeView)
 {
     this.state = state;
     InitStyles();
 }
		public void EventLineGUI(Rect rect, AnimationSelection selection, AnimationWindowState state, CurveEditor curveEditor)
		{
			AnimationClip activeAnimationClip = state.m_ActiveAnimationClip;
			GameObject rootGameObject = state.m_RootGameObject;
			GUI.BeginGroup(rect);
			Color color = GUI.color;
			Rect rect2 = new Rect(0f, 0f, rect.width, rect.height);
			float time = (float)Mathf.RoundToInt(state.PixelToTime(Event.current.mousePosition.x, rect) * state.frameRate) / state.frameRate;
			if (activeAnimationClip != null)
			{
				AnimationEvent[] animationEvents = AnimationUtility.GetAnimationEvents(activeAnimationClip);
				Texture image = EditorGUIUtility.IconContent("Animation.EventMarker").image;
				Rect[] array = new Rect[animationEvents.Length];
				Rect[] array2 = new Rect[animationEvents.Length];
				int num = 1;
				int num2 = 0;
				for (int i = 0; i < animationEvents.Length; i++)
				{
					AnimationEvent animationEvent = animationEvents[i];
					if (num2 == 0)
					{
						num = 1;
						while (i + num < animationEvents.Length && animationEvents[i + num].time == animationEvent.time)
						{
							num++;
						}
						num2 = num;
					}
					num2--;
					float num3 = Mathf.Floor(state.FrameToPixel(animationEvent.time * activeAnimationClip.frameRate, rect));
					int num4 = 0;
					if (num > 1)
					{
						float num5 = (float)Mathf.Min((num - 1) * (image.width - 1), (int)(state.FrameDeltaToPixel(rect) - (float)(image.width * 2)));
						num4 = Mathf.FloorToInt(Mathf.Max(0f, num5 - (float)((image.width - 1) * num2)));
					}
					Rect rect3 = new Rect(num3 + (float)num4 - (float)(image.width / 2), (rect.height - 10f) * (float)(num2 - num + 1) / (float)Mathf.Max(1, num - 1), (float)image.width, (float)image.height);
					array[i] = rect3;
					array2[i] = rect3;
				}
				if (this.m_DirtyTooltip)
				{
					if (this.m_HoverEvent >= 0 && this.m_HoverEvent < array.Length)
					{
						this.m_InstantTooltipText = AnimationEventPopup.FormatEvent(rootGameObject, animationEvents[this.m_HoverEvent]);
						this.m_InstantTooltipPoint = new Vector2(array[this.m_HoverEvent].xMin + (float)((int)(array[this.m_HoverEvent].width / 2f)) + rect.x - 30f, rect.yMax);
					}
					this.m_DirtyTooltip = false;
				}
				if (this.m_EventsSelected == null || this.m_EventsSelected.Length != animationEvents.Length)
				{
					this.m_EventsSelected = new bool[animationEvents.Length];
					AnimationEventPopup.ClosePopup();
				}
				Vector2 zero = Vector2.zero;
				int num6;
				float num7;
				float num8;
				HighLevelEvent highLevelEvent = EditorGUIExt.MultiSelection(rect, array2, new GUIContent(image), array, ref this.m_EventsSelected, null, out num6, out zero, out num7, out num8, GUIStyleX.none);
				if (highLevelEvent != HighLevelEvent.None)
				{
					switch (highLevelEvent)
					{
					case HighLevelEvent.DoubleClick:
						if (num6 != -1)
						{
							AnimationEventPopup.Edit(rootGameObject, selection.clip, num6, this.m_Owner);
						}
						else
						{
							this.EventLineContextMenuAdd(new AnimationEventTimeLine.EventLineContextMenuObject(rootGameObject, activeAnimationClip, time, -1));
						}
						break;
					case HighLevelEvent.ContextClick:
					{
						GenericMenu genericMenu = new GenericMenu();
						AnimationEventTimeLine.EventLineContextMenuObject userData = new AnimationEventTimeLine.EventLineContextMenuObject(rootGameObject, activeAnimationClip, animationEvents[num6].time, num6);
						genericMenu.AddItem(new GUIContent("Edit Animation Event"), false, new GenericMenu.MenuFunction2(this.EventLineContextMenuEdit), userData);
						genericMenu.AddItem(new GUIContent("Add Animation Event"), false, new GenericMenu.MenuFunction2(this.EventLineContextMenuAdd), userData);
						genericMenu.AddItem(new GUIContent("Delete Animation Event"), false, new GenericMenu.MenuFunction2(this.EventLineContextMenuDelete), userData);
						genericMenu.ShowAsContext();
						this.m_InstantTooltipText = null;
						this.m_DirtyTooltip = true;
						state.Repaint();
						break;
					}
					case HighLevelEvent.BeginDrag:
						this.m_EventsAtMouseDown = animationEvents;
						this.m_EventTimes = new float[animationEvents.Length];
						for (int j = 0; j < animationEvents.Length; j++)
						{
							this.m_EventTimes[j] = animationEvents[j].time;
						}
						break;
					case HighLevelEvent.Drag:
					{
						for (int k = animationEvents.Length - 1; k >= 0; k--)
						{
							if (this.m_EventsSelected[k])
							{
								AnimationEvent animationEvent2 = this.m_EventsAtMouseDown[k];
								animationEvent2.time = this.m_EventTimes[k] + zero.x * state.PixelDeltaToTime(rect);
								animationEvent2.time = Mathf.Max(0f, animationEvent2.time);
								animationEvent2.time = (float)Mathf.RoundToInt(animationEvent2.time * activeAnimationClip.frameRate) / activeAnimationClip.frameRate;
								this.m_EventsAtMouseDown[k] = animationEvent2;
							}
						}
						int[] array3 = new int[this.m_EventsSelected.Length];
						for (int l = 0; l < array3.Length; l++)
						{
							array3[l] = l;
						}
						Array.Sort(this.m_EventsAtMouseDown, array3, new AnimationEventTimeLine.EventComparer());
						bool[] array4 = (bool[])this.m_EventsSelected.Clone();
						float[] array5 = (float[])this.m_EventTimes.Clone();
						for (int m = 0; m < array3.Length; m++)
						{
							this.m_EventsSelected[m] = array4[array3[m]];
							this.m_EventTimes[m] = array5[array3[m]];
						}
						Undo.RegisterCompleteObjectUndo(activeAnimationClip, "Move Event");
						AnimationUtility.SetAnimationEvents(activeAnimationClip, this.m_EventsAtMouseDown);
						this.m_DirtyTooltip = true;
						break;
					}
					case HighLevelEvent.Delete:
						this.DeleteEvents(activeAnimationClip, this.m_EventsSelected);
						break;
					case HighLevelEvent.SelectionChanged:
						curveEditor.SelectNone();
						if (num6 != -1)
						{
							AnimationEventPopup.UpdateSelection(rootGameObject, selection.clip, num6, this.m_Owner);
						}
						break;
					}
				}
				this.CheckRectsOnMouseMove(rect, animationEvents, array);
			}
			if (Event.current.type == EventType.ContextClick && rect2.Contains(Event.current.mousePosition) && selection.EnsureClipPresence())
			{
				Event.current.Use();
				GenericMenu genericMenu2 = new GenericMenu();
				genericMenu2.AddItem(new GUIContent("Add Animation Event"), false, new GenericMenu.MenuFunction2(this.EventLineContextMenuAdd), new AnimationEventTimeLine.EventLineContextMenuObject(rootGameObject, activeAnimationClip, time, -1));
				genericMenu2.ShowAsContext();
			}
			GUI.color = color;
			GUI.EndGroup();
		}
 public static UndoPropertyModification[] Process(AnimationWindowState state, UndoPropertyModification[] modifications)
 {
   GameObject activeRootGameObject = state.activeRootGameObject;
   if ((UnityEngine.Object) activeRootGameObject == (UnityEngine.Object) null)
     return modifications;
   AnimationClip activeAnimationClip = state.activeAnimationClip;
   Animator component = activeRootGameObject.GetComponent<Animator>();
   if (!AnimationRecording.HasAnyRecordableModifications(activeRootGameObject, modifications))
     return modifications;
   AnimationRecording.ProcessRotationModifications(state, ref modifications);
   List<UndoPropertyModification> propertyModificationList = new List<UndoPropertyModification>();
   for (int index1 = 0; index1 < modifications.Length; ++index1)
   {
     EditorCurveBinding binding = new EditorCurveBinding();
     PropertyModification previousValue = modifications[index1].previousValue;
     System.Type editorCurveBinding = AnimationUtility.PropertyModificationToEditorCurveBinding(previousValue, activeRootGameObject, out binding);
     if (editorCurveBinding != null && editorCurveBinding != typeof (Animator))
     {
       if ((UnityEngine.Object) component != (UnityEngine.Object) null && component.isHuman && (binding.type == typeof (Transform) && component.IsBoneTransform(previousValue.target as Transform)))
       {
         Debug.LogWarning((object) "Keyframing for humanoid rig is not supported!", (UnityEngine.Object) (previousValue.target as Transform));
       }
       else
       {
         AnimationMode.AddPropertyModification(binding, previousValue, modifications[index1].keepPrefabOverride);
         EditorCurveBinding[] editorCurveBindingArray = RotationCurveInterpolation.RemapAnimationBindingForAddKey(binding, activeAnimationClip);
         if (editorCurveBindingArray != null)
         {
           for (int index2 = 0; index2 < editorCurveBindingArray.Length; ++index2)
             AnimationRecording.AddKey(state, editorCurveBindingArray[index2], editorCurveBinding, AnimationRecording.FindPropertyModification(activeRootGameObject, modifications, editorCurveBindingArray[index2]));
         }
         else
           AnimationRecording.AddKey(state, binding, editorCurveBinding, previousValue);
       }
     }
     else
       propertyModificationList.Add(modifications[index1]);
   }
   return propertyModificationList.ToArray();
 }
		public AnimationWindowHierarchyDataSource(TreeView treeView, AnimationWindowState animationWindowState) : base(treeView)
		{
			this.state = animationWindowState;
		}
 public static void AddSelectedKeyframes(AnimationWindowState state, AnimationKeyTime time)
 {
   if (state.activeCurves.Count > 0)
   {
     using (List<AnimationWindowCurve>.Enumerator enumerator = state.activeCurves.GetEnumerator())
     {
       while (enumerator.MoveNext())
       {
         AnimationWindowCurve current = enumerator.Current;
         AnimationWindowUtility.AddKeyframeToCurve(state, current, time);
       }
     }
   }
   else
   {
     using (List<AnimationWindowCurve>.Enumerator enumerator = state.allCurves.GetEnumerator())
     {
       while (enumerator.MoveNext())
       {
         AnimationWindowCurve current = enumerator.Current;
         AnimationWindowUtility.AddKeyframeToCurve(state, current, time);
       }
     }
   }
 }
 private static void AddKey(AnimationWindowState state, EditorCurveBinding binding, System.Type type, PropertyModification modification)
 {
   GameObject activeRootGameObject = state.activeRootGameObject;
   AnimationClip activeAnimationClip = state.activeAnimationClip;
   if ((activeAnimationClip.hideFlags & HideFlags.NotEditable) != HideFlags.None)
     return;
   AnimationWindowCurve curve = new AnimationWindowCurve(activeAnimationClip, binding, type);
   object currentValue = CurveBindingUtility.GetCurrentValue(activeRootGameObject, binding);
   if (curve.length == 0)
   {
     object outObject = (object) null;
     if (!AnimationRecording.ValueFromPropertyModification(modification, binding, out outObject))
       outObject = currentValue;
     if (state.frame != 0)
       AnimationWindowUtility.AddKeyframeToCurve(curve, outObject, type, AnimationKeyTime.Frame(0, activeAnimationClip.frameRate));
   }
   AnimationWindowUtility.AddKeyframeToCurve(curve, currentValue, type, AnimationKeyTime.Frame(state.frame, activeAnimationClip.frameRate));
   state.SaveCurve(curve);
 }