예제 #1
0
        private static void ProcessRootMotionModifications(IAnimationRecordingState state, ref Dictionary <object, AnimationRecording.RootMotionModification> rootMotionModifications)
        {
            AnimationClip activeAnimationClip  = state.activeAnimationClip;
            GameObject    activeRootGameObject = state.activeRootGameObject;
            Animator      component            = activeRootGameObject.GetComponent <Animator>();
            bool          flag = component != null && component.isHuman;

            foreach (KeyValuePair <object, AnimationRecording.RootMotionModification> current in rootMotionModifications)
            {
                AnimationRecording.RootMotionModification value = current.Value;
                Transform  transform     = current.Key as Transform;
                Vector3    vector        = transform.localScale * ((!flag) ? 1f : component.humanScale);
                Vector3    localPosition = transform.localPosition;
                Quaternion localRotation = transform.localRotation;
                if (value.lastP.previousValue != null)
                {
                    AnimationRecording.ProcessAnimatorModification(state, component, value.px, "MotionT.x", localPosition.x, vector.x);
                    AnimationRecording.ProcessAnimatorModification(state, component, value.py, "MotionT.y", localPosition.y, vector.y);
                    AnimationRecording.ProcessAnimatorModification(state, component, value.pz, "MotionT.z", localPosition.z, vector.z);
                }
                if (value.lastR.previousValue != null)
                {
                    AnimationRecording.ProcessAnimatorModification(state, component, value.rx, "MotionQ.x", localRotation.x, 1f);
                    AnimationRecording.ProcessAnimatorModification(state, component, value.ry, "MotionQ.y", localRotation.y, 1f);
                    AnimationRecording.ProcessAnimatorModification(state, component, value.rz, "MotionQ.z", localRotation.z, 1f);
                    AnimationRecording.ProcessAnimatorModification(state, component, value.rw, "MotionQ.w", localRotation.w, 1f);
                }
            }
        }
        private UndoPropertyModification[] RegisterCandidates(UndoPropertyModification[] modifications)
        {
            bool createNewClip = (m_CandidateClip == null);

            if (createNewClip)
            {
                m_CandidateClip        = new AnimationClip();
                m_CandidateClip.legacy = state.activeAnimationClip.legacy;
                m_CandidateClip.name   = "CandidateClip";

                StartCandidateRecording();
            }

            CandidateRecordingState recordingState = new CandidateRecordingState(state, m_CandidateClip);

            UndoPropertyModification[] discardedModifications = AnimationRecording.Process(recordingState, modifications);

            // No modifications were added to the candidate clip, discard.
            if (createNewClip && discardedModifications.Length == modifications.Length)
            {
                ClearCandidates();
            }

            // Make sure inspector is repainted after adding new candidates to get appropriate feedback.
            InspectorWindow.RepaintAllInspectors();

            return(discardedModifications);
        }
예제 #3
0
        private static UndoPropertyModification[] FilterRotationModifications(IAnimationRecordingState state, ref Dictionary <object, AnimationRecording.RotationModification> rotationModifications)
        {
            AnimationClip activeAnimationClip  = state.activeAnimationClip;
            GameObject    activeRootGameObject = state.activeRootGameObject;
            List <object> list = new List <object>();
            List <UndoPropertyModification> list2 = new List <UndoPropertyModification>();

            foreach (KeyValuePair <object, AnimationRecording.RotationModification> current in rotationModifications)
            {
                AnimationRecording.RotationModification value = current.Value;
                if (state.DiscardModification(value.lastQuatModification.currentValue))
                {
                    AnimationRecording.DiscardRotationModification(value, ref list2);
                    list.Add(current.Key);
                }
                else
                {
                    EditorCurveBinding editorCurveBinding = default(EditorCurveBinding);
                    if (AnimationUtility.PropertyModificationToEditorCurveBinding(value.lastQuatModification.currentValue, activeRootGameObject, out editorCurveBinding) == null)
                    {
                        AnimationRecording.DiscardRotationModification(value, ref list2);
                        list.Add(current.Key);
                    }
                }
            }
            foreach (object current2 in list)
            {
                rotationModifications.Remove(current2);
            }
            return(list2.ToArray());
        }
예제 #4
0
        public static UndoPropertyModification[] Process(IAnimationRecordingState state, UndoPropertyModification[] modifications)
        {
            GameObject activeRootGameObject = state.activeRootGameObject;

            UndoPropertyModification[] result;
            if (activeRootGameObject == null)
            {
                result = modifications;
            }
            else if (!AnimationRecording.HasAnyRecordableModifications(activeRootGameObject, modifications))
            {
                result = modifications;
            }
            else
            {
                Dictionary <object, AnimationRecording.RotationModification> dictionary  = new Dictionary <object, AnimationRecording.RotationModification>();
                Dictionary <object, AnimationRecording.Vector3Modification>  dictionary2 = new Dictionary <object, AnimationRecording.Vector3Modification>();
                Dictionary <object, AnimationRecording.Vector3Modification>  dictionary3 = new Dictionary <object, AnimationRecording.Vector3Modification>();
                AnimationRecording.CollectRotationModifications(state, ref modifications, ref dictionary);
                UndoPropertyModification[] second = AnimationRecording.FilterRotationModifications(state, ref dictionary);
                UndoPropertyModification[] array  = AnimationRecording.FilterModifications(state, ref modifications);
                AnimationRecording.CollectVector3Modifications(state, ref modifications, ref dictionary3, "m_LocalPosition");
                AnimationRecording.CollectVector3Modifications(state, ref modifications, ref dictionary2, "m_LocalScale");
                AnimationRecording.ProcessAnimatorModifications(state, ref dictionary3, ref dictionary, ref dictionary2);
                AnimationRecording.ProcessVector3Modifications(state, ref dictionary3);
                AnimationRecording.ProcessRotationModifications(state, ref dictionary);
                AnimationRecording.ProcessVector3Modifications(state, ref dictionary2);
                AnimationRecording.ProcessModifications(state, modifications);
                array.Concat(second);
                result = array.ToArray <UndoPropertyModification>();
            }
            return(result);
        }
예제 #5
0
        private static void AddKey(IAnimationRecordingState state, EditorCurveBinding binding, Type type, PropertyModification modification)
        {
            GameObject    activeRootGameObject = state.activeRootGameObject;
            AnimationClip activeAnimationClip  = state.activeAnimationClip;

            if ((activeAnimationClip.hideFlags & HideFlags.NotEditable) == HideFlags.None)
            {
                AnimationWindowCurve animationWindowCurve = new AnimationWindowCurve(activeAnimationClip, binding, type);
                object currentValue = CurveBindingUtility.GetCurrentValue(activeRootGameObject, binding);
                if (animationWindowCurve.length == 0)
                {
                    object value = null;
                    if (!AnimationRecording.ValueFromPropertyModification(modification, binding, out value))
                    {
                        value = currentValue;
                    }
                    if (state.frame != 0)
                    {
                        AnimationWindowUtility.AddKeyframeToCurve(animationWindowCurve, value, type, AnimationKeyTime.Frame(0, activeAnimationClip.frameRate));
                    }
                }
                AnimationWindowUtility.AddKeyframeToCurve(animationWindowCurve, currentValue, type, AnimationKeyTime.Frame(state.frame, activeAnimationClip.frameRate));
                state.SaveCurve(animationWindowCurve);
            }
        }
 private UndoPropertyModification[] ProcessAutoKey(UndoPropertyModification[] modifications)
 {
     this.BeginKeyModification();
     AnimationWindowControl.RecordingState recordingState = new AnimationWindowControl.RecordingState(this.state, AnimationWindowControl.RecordingStateMode.AutoKey);
     UndoPropertyModification[]            result         = AnimationRecording.Process(recordingState, modifications);
     this.EndKeyModification();
     return(result);
 }
예제 #7
0
        public static UndoPropertyModification[] Process(IAnimationRecordingState state, UndoPropertyModification[] modifications)
        {
            GameObject activeRootGameObject = state.activeRootGameObject;

            if (activeRootGameObject == 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> 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)
                {
                    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());
        }
예제 #8
0
        private UndoPropertyModification[] ProcessAutoKey(UndoPropertyModification[] modifications)
        {
            BeginKeyModification();

            RecordingState recordingState = new RecordingState(state, RecordingStateMode.AutoKey);

            UndoPropertyModification[] discardedModifications = AnimationRecording.Process(recordingState, modifications);

            EndKeyModification();

            return(discardedModifications);
        }
예제 #9
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());
        }
예제 #10
0
        public static UndoPropertyModification[] ProcessModifications(IAnimationRecordingState state, UndoPropertyModification[] modifications)
        {
            AnimationClip activeAnimationClip  = state.activeAnimationClip;
            GameObject    activeRootGameObject = state.activeRootGameObject;
            Animator      component            = activeRootGameObject.GetComponent <Animator>();

            UndoPropertyModification[] result = AnimationRecording.FilterModifications(state, ref modifications);
            int i = 0;

            while (i < modifications.Length)
            {
                EditorCurveBinding   binding       = default(EditorCurveBinding);
                PropertyModification previousValue = modifications[i].previousValue;
                Type type = AnimationUtility.PropertyModificationToEditorCurveBinding(previousValue, activeRootGameObject, out binding);
                if (type != null)
                {
                    if (component != null && component.isHuman && binding.type == typeof(Transform) && component.gameObject.transform != previousValue.target && component.IsBoneTransform(previousValue.target as Transform))
                    {
                        Debug.LogWarning("Keyframing for humanoid rig is not supported!", previousValue.target as Transform);
                    }
                    else
                    {
                        EditorCurveBinding[] array = RotationCurveInterpolation.RemapAnimationBindingForAddKey(binding, activeAnimationClip);
                        if (array != null)
                        {
                            for (int j = 0; j < array.Length; j++)
                            {
                                PropertyModification propertyModification = AnimationRecording.FindPropertyModification(activeRootGameObject, modifications, array[j]);
                                if (propertyModification == null)
                                {
                                    propertyModification = AnimationRecording.CreateDummyPropertyModification(activeRootGameObject, previousValue, array[j]);
                                }
                                state.AddPropertyModification(array[j], propertyModification, modifications[i].keepPrefabOverride);
                                AnimationRecording.AddKey(state, array[j], type, propertyModification);
                            }
                        }
                        else
                        {
                            state.AddPropertyModification(binding, previousValue, modifications[i].keepPrefabOverride);
                            AnimationRecording.AddKey(state, binding, type, previousValue);
                        }
                    }
                }
IL_19A:
                i++;
                continue;
                goto IL_19A;
            }
            return(result);
        }
예제 #11
0
 private UndoPropertyModification[] PostprocessAnimationRecordingModifications(UndoPropertyModification[] modifications)
 {
     UndoPropertyModification[] result;
     if (!AnimationMode.InAnimationMode())
     {
         Undo.postprocessModifications = (Undo.PostprocessModifications)Delegate.Remove(Undo.postprocessModifications, new Undo.PostprocessModifications(this.PostprocessAnimationRecordingModifications));
         result = modifications;
     }
     else
     {
         result = AnimationRecording.Process(this.state, modifications);
     }
     return(result);
 }
예제 #12
0
        private static void ProcessVector3Modification(IAnimationRecordingState state, EditorCurveBinding baseBinding, UndoPropertyModification modification, Transform target, string axis)
        {
            EditorCurveBinding   editorCurveBinding   = baseBinding;
            PropertyModification propertyModification = modification.previousValue;

            editorCurveBinding.propertyName = editorCurveBinding.propertyName.Remove(editorCurveBinding.propertyName.Length - 1, 1) + axis;
            if (propertyModification == null)
            {
                propertyModification              = new PropertyModification();
                propertyModification.target       = target;
                propertyModification.propertyPath = editorCurveBinding.propertyName;
                object currentValue = CurveBindingUtility.GetCurrentValue(state.activeRootGameObject, editorCurveBinding);
                propertyModification.value = ((float)currentValue).ToString();
            }
            state.AddPropertyModification(editorCurveBinding, propertyModification, modification.keepPrefabOverride);
            AnimationRecording.AddKey(state, editorCurveBinding, typeof(float), propertyModification);
        }
 public void AddKey(PropertyModification[] modifications)
 {
     UndoPropertyModification[] array = new UndoPropertyModification[modifications.Length];
     for (int i = 0; i < modifications.Length; i++)
     {
         PropertyModification propertyModification = modifications[i];
         array[i].previousValue = propertyModification;
         array[i].currentValue  = propertyModification;
     }
     this.BeginKeyModification();
     AnimationWindowControl.RecordingState recordingState = new AnimationWindowControl.RecordingState(this.state, AnimationWindowControl.RecordingStateMode.ManualKey);
     AnimationRecording.Process(recordingState, array);
     this.EndKeyModification();
     this.RemoveFromCandidates(modifications);
     this.ResampleAnimation();
     this.state.Repaint();
 }
예제 #14
0
        public static void ProcessModifications(IAnimationRecordingState state, UndoPropertyModification[] modifications)
        {
            AnimationClip activeAnimationClip  = state.activeAnimationClip;
            GameObject    activeRootGameObject = state.activeRootGameObject;

            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)
                {
                    state.AddPropertyModification(binding, previousValue, modifications[i].keepPrefabOverride);
                    AnimationRecording.AddKey(state, binding, type, previousValue);
                }
            }
        }
예제 #15
0
        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);
        }
        private UndoPropertyModification[] RegisterCandidates(UndoPropertyModification[] modifications)
        {
            bool flag = this.m_CandidateClip == null;

            if (flag)
            {
                this.m_CandidateClip        = new AnimationClip();
                this.m_CandidateClip.legacy = this.state.activeAnimationClip.legacy;
                this.m_CandidateClip.name   = "CandidateClip";
                this.StartCandidateRecording();
            }
            AnimationWindowControl.CandidateRecordingState candidateRecordingState = new AnimationWindowControl.CandidateRecordingState(this.state, this.m_CandidateClip);
            UndoPropertyModification[] array = AnimationRecording.Process(candidateRecordingState, modifications);
            if (flag && array.Length == modifications.Length)
            {
                this.ClearCandidates();
            }
            InspectorWindow.RepaintAllInspectors();
            return(array);
        }
예제 #17
0
        public static void ProcessVector3Modifications(IAnimationRecordingState state, ref Dictionary <object, AnimationRecording.Vector3Modification> vector3Modifications)
        {
            AnimationClip activeAnimationClip  = state.activeAnimationClip;
            GameObject    activeRootGameObject = state.activeRootGameObject;

            foreach (KeyValuePair <object, AnimationRecording.Vector3Modification> current in vector3Modifications)
            {
                AnimationRecording.Vector3Modification value = current.Value;
                Transform transform = current.Key as Transform;
                if (!(transform == null))
                {
                    EditorCurveBinding baseBinding = default(EditorCurveBinding);
                    if (AnimationUtility.PropertyModificationToEditorCurveBinding(value.last.currentValue, state.activeRootGameObject, out baseBinding) != null)
                    {
                        AnimationRecording.ProcessVector3Modification(state, baseBinding, value.x, transform, "x");
                        AnimationRecording.ProcessVector3Modification(state, baseBinding, value.y, transform, "y");
                        AnimationRecording.ProcessVector3Modification(state, baseBinding, value.z, transform, "z");
                    }
                }
            }
        }
예제 #18
0
        public static UndoPropertyModification[] Process(IAnimationRecordingState state, UndoPropertyModification[] modifications)
        {
            GameObject activeRootGameObject = state.activeRootGameObject;

            UndoPropertyModification[] result;
            if (activeRootGameObject == null)
            {
                result = modifications;
            }
            else if (!AnimationRecording.HasAnyRecordableModifications(activeRootGameObject, modifications))
            {
                result = modifications;
            }
            else
            {
                UndoPropertyModification[] first  = AnimationRecording.ProcessRotationModifications(state, ref modifications);
                UndoPropertyModification[] second = AnimationRecording.ProcessModifications(state, modifications);
                result = first.Concat(second).ToArray <UndoPropertyModification>();
            }
            return(result);
        }
예제 #19
0
        private static void ProcessAnimatorModification(IAnimationRecordingState state, Animator animator, UndoPropertyModification modification, string name, float value, float scale)
        {
            AnimationClip activeAnimationClip = state.activeAnimationClip;

            if ((activeAnimationClip.hideFlags & HideFlags.NotEditable) == HideFlags.None)
            {
                float  num = value;
                object obj;
                if (AnimationRecording.ValueFromPropertyModification(modification.currentValue, default(EditorCurveBinding), out obj))
                {
                    value = (float)obj;
                }
                if (AnimationRecording.ValueFromPropertyModification(modification.previousValue, default(EditorCurveBinding), out obj))
                {
                    num = (float)obj;
                }
                value = ((Mathf.Abs(scale) <= Mathf.Epsilon) ? value : (value / scale));
                num   = ((Mathf.Abs(scale) <= Mathf.Epsilon) ? num : (num / scale));
                EditorCurveBinding binding = default(EditorCurveBinding);
                binding.propertyName = name;
                binding.path         = "";
                binding.type         = typeof(Animator);
                PropertyModification propertyModification = new PropertyModification();
                propertyModification.target       = animator;
                propertyModification.propertyPath = binding.propertyName;
                propertyModification.value        = value.ToString();
                state.AddPropertyModification(binding, propertyModification, modification.keepPrefabOverride);
                AnimationWindowCurve animationWindowCurve = new AnimationWindowCurve(activeAnimationClip, binding, typeof(float));
                if (state.addZeroFrame && state.currentFrame != 0 && animationWindowCurve.length == 0)
                {
                    AnimationWindowUtility.AddKeyframeToCurve(animationWindowCurve, num, typeof(float), AnimationKeyTime.Frame(0, activeAnimationClip.frameRate));
                }
                AnimationWindowUtility.AddKeyframeToCurve(animationWindowCurve, value, typeof(float), AnimationKeyTime.Frame(state.currentFrame, activeAnimationClip.frameRate));
                state.SaveCurve(animationWindowCurve);
            }
        }
예제 #20
0
        private UndoPropertyModification[] RegisterCandidates(UndoPropertyModification[] modifications)
        {
            bool hasCandidates = AnimationMode.IsRecordingCandidates();

            if (!hasCandidates)
            {
                StartCandidateRecording();
            }

            CandidateRecordingState recordingState = new CandidateRecordingState(state, m_CandidateClip);

            UndoPropertyModification[] discardedModifications = AnimationRecording.Process(recordingState, modifications);

            // No modifications were added to the candidate clip, stop recording candidates.
            if (!hasCandidates && discardedModifications.Length == modifications.Length)
            {
                StopCandidateRecording();
            }

            // Make sure inspector is repainted after adding new candidates to get appropriate feedback.
            InspectorWindow.RepaintAllInspectors();

            return(discardedModifications);
        }
예제 #21
0
        public void AddKey(PropertyModification[] modifications)
        {
            var undoModifications = new UndoPropertyModification[modifications.Length];

            for (int i = 0; i < modifications.Length; ++i)
            {
                var modification = modifications[i];
                undoModifications[i].previousValue = modification;
                undoModifications[i].currentValue  = modification;
            }

            BeginKeyModification();

            var recordingState = new RecordingState(state, RecordingStateMode.ManualKey);

            AnimationRecording.Process(recordingState, undoModifications);

            EndKeyModification();

            RemoveFromCandidates(modifications);

            ResampleAnimation();
            state.Repaint();
        }
예제 #22
0
        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);
                }
            }
        }
예제 #23
0
        private static void ProcessRotationModifications(IAnimationRecordingState state, ref UndoPropertyModification[] modifications)
        {
            Dictionary <object, AnimationRecording.RotationModification> dictionary = new Dictionary <object, AnimationRecording.RotationModification>();

            AnimationRecording.CollectRotationModifications(state, ref modifications, ref dictionary);
            foreach (KeyValuePair <object, AnimationRecording.RotationModification> current in dictionary)
            {
                AnimationRecording.RotationModification value = current.Value;
                Transform transform = current.Key as Transform;
                if (!(transform == null))
                {
                    EditorCurveBinding editorCurveBinding = default(EditorCurveBinding);
                    Type type = AnimationUtility.PropertyModificationToEditorCurveBinding(value.lastQuatModification.currentValue, state.activeRootGameObject, out editorCurveBinding);
                    if (type != null)
                    {
                        AnimationRecording.AddRotationPropertyModification(state, editorCurveBinding, value.x);
                        AnimationRecording.AddRotationPropertyModification(state, editorCurveBinding, value.y);
                        AnimationRecording.AddRotationPropertyModification(state, editorCurveBinding, value.z);
                        AnimationRecording.AddRotationPropertyModification(state, editorCurveBinding, value.w);
                        if (value.useEuler)
                        {
                            AnimationRecording.AddRotationPropertyModification(state, editorCurveBinding, value.eulerX);
                            AnimationRecording.AddRotationPropertyModification(state, editorCurveBinding, value.eulerY);
                            AnimationRecording.AddRotationPropertyModification(state, editorCurveBinding, value.eulerZ);
                            Vector3 localEulerAngles  = transform.GetLocalEulerAngles(RotationOrder.OrderZXY);
                            Vector3 localEulerAngles2 = transform.GetLocalEulerAngles(RotationOrder.OrderZXY);
                            object  obj;
                            if (AnimationRecording.ValueFromPropertyModification(value.eulerX.previousValue, editorCurveBinding, out obj))
                            {
                                localEulerAngles.x = (float)obj;
                            }
                            object obj2;
                            if (AnimationRecording.ValueFromPropertyModification(value.eulerY.previousValue, editorCurveBinding, out obj2))
                            {
                                localEulerAngles.y = (float)obj2;
                            }
                            object obj3;
                            if (AnimationRecording.ValueFromPropertyModification(value.eulerZ.previousValue, editorCurveBinding, out obj3))
                            {
                                localEulerAngles.z = (float)obj3;
                            }
                            if (AnimationRecording.ValueFromPropertyModification(value.eulerX.currentValue, editorCurveBinding, out obj))
                            {
                                localEulerAngles2.x = (float)obj;
                            }
                            if (AnimationRecording.ValueFromPropertyModification(value.eulerY.currentValue, editorCurveBinding, out obj2))
                            {
                                localEulerAngles2.y = (float)obj2;
                            }
                            if (AnimationRecording.ValueFromPropertyModification(value.eulerZ.currentValue, editorCurveBinding, out obj3))
                            {
                                localEulerAngles2.z = (float)obj3;
                            }
                            AnimationRecording.AddRotationKey(state, editorCurveBinding, type, localEulerAngles, localEulerAngles2);
                        }
                        else
                        {
                            Quaternion localRotation  = transform.localRotation;
                            Quaternion localRotation2 = transform.localRotation;
                            object     obj4;
                            if (AnimationRecording.ValueFromPropertyModification(value.x.previousValue, editorCurveBinding, out obj4))
                            {
                                localRotation.x = (float)obj4;
                            }
                            object obj5;
                            if (AnimationRecording.ValueFromPropertyModification(value.y.previousValue, editorCurveBinding, out obj5))
                            {
                                localRotation.y = (float)obj5;
                            }
                            object obj6;
                            if (AnimationRecording.ValueFromPropertyModification(value.z.previousValue, editorCurveBinding, out obj6))
                            {
                                localRotation.z = (float)obj6;
                            }
                            object obj7;
                            if (AnimationRecording.ValueFromPropertyModification(value.w.previousValue, editorCurveBinding, out obj7))
                            {
                                localRotation.w = (float)obj7;
                            }
                            if (AnimationRecording.ValueFromPropertyModification(value.x.currentValue, editorCurveBinding, out obj4))
                            {
                                localRotation2.x = (float)obj4;
                            }
                            if (AnimationRecording.ValueFromPropertyModification(value.y.currentValue, editorCurveBinding, out obj5))
                            {
                                localRotation2.y = (float)obj5;
                            }
                            if (AnimationRecording.ValueFromPropertyModification(value.z.currentValue, editorCurveBinding, out obj6))
                            {
                                localRotation2.z = (float)obj6;
                            }
                            if (AnimationRecording.ValueFromPropertyModification(value.w.currentValue, editorCurveBinding, out obj7))
                            {
                                localRotation2.w = (float)obj7;
                            }
                            AnimationRecording.AddRotationKey(state, editorCurveBinding, type, localRotation.eulerAngles, localRotation2.eulerAngles);
                        }
                    }
                }
            }
        }
예제 #24
0
        private static void ProcessAnimatorModifications(IAnimationRecordingState state, ref Dictionary <object, AnimationRecording.Vector3Modification> positionModifications, ref Dictionary <object, AnimationRecording.RotationModification> rotationModifications, ref Dictionary <object, AnimationRecording.Vector3Modification> scaleModifications)
        {
            Dictionary <object, AnimationRecording.RootMotionModification> dictionary = new Dictionary <object, AnimationRecording.RootMotionModification>();
            AnimationClip activeAnimationClip  = state.activeAnimationClip;
            GameObject    activeRootGameObject = state.activeRootGameObject;
            Animator      component            = activeRootGameObject.GetComponent <Animator>();
            bool          flag  = component != null && component.isHuman;
            bool          flag2 = component != null && component.hasRootMotion;
            bool          flag3 = component != null && component.applyRootMotion;
            List <object> list  = new List <object>();

            foreach (KeyValuePair <object, AnimationRecording.Vector3Modification> current in positionModifications)
            {
                AnimationRecording.Vector3Modification value = current.Value;
                Transform transform = current.Key as Transform;
                if (!(transform == null))
                {
                    EditorCurveBinding editorCurveBinding = default(EditorCurveBinding);
                    if (AnimationUtility.PropertyModificationToEditorCurveBinding(value.last.currentValue, state.activeRootGameObject, out editorCurveBinding) != null)
                    {
                        bool flag4 = activeRootGameObject.transform == transform;
                        bool flag5 = (flag || flag2 || flag3) && flag4;
                        bool flag6 = flag && !flag4 && component.IsBoneTransform(transform);
                        if (flag6)
                        {
                            Debug.LogWarning("Keyframing translation on humanoid rig is not supported!", transform);
                            list.Add(current.Key);
                        }
                        else if (flag5)
                        {
                            AnimationRecording.RootMotionModification rootMotionModification;
                            if (!dictionary.TryGetValue(transform, out rootMotionModification))
                            {
                                rootMotionModification = new AnimationRecording.RootMotionModification();
                                dictionary[transform]  = rootMotionModification;
                            }
                            rootMotionModification.lastP = value.last;
                            rootMotionModification.px    = value.x;
                            rootMotionModification.py    = value.y;
                            rootMotionModification.pz    = value.z;
                            list.Add(current.Key);
                        }
                    }
                }
            }
            foreach (object current2 in list)
            {
                positionModifications.Remove(current2);
            }
            List <object> list2 = new List <object>();

            foreach (KeyValuePair <object, AnimationRecording.RotationModification> current3 in rotationModifications)
            {
                AnimationRecording.RotationModification value2 = current3.Value;
                Transform transform2 = current3.Key as Transform;
                if (!(transform2 == null))
                {
                    EditorCurveBinding editorCurveBinding2 = default(EditorCurveBinding);
                    if (AnimationUtility.PropertyModificationToEditorCurveBinding(value2.lastQuatModification.currentValue, state.activeRootGameObject, out editorCurveBinding2) != null)
                    {
                        bool flag7 = activeRootGameObject.transform == transform2;
                        bool flag8 = (flag || flag2 || flag3) && flag7;
                        bool flag9 = flag && !flag7 && component.IsBoneTransform(transform2);
                        if (flag9)
                        {
                            Debug.LogWarning("Keyframing rotation on humanoid rig is not supported!", transform2);
                            list2.Add(current3.Key);
                        }
                        else if (flag8)
                        {
                            AnimationRecording.RootMotionModification rootMotionModification2;
                            if (!dictionary.TryGetValue(transform2, out rootMotionModification2))
                            {
                                rootMotionModification2 = new AnimationRecording.RootMotionModification();
                                dictionary[transform2]  = rootMotionModification2;
                            }
                            rootMotionModification2.lastR = value2.lastQuatModification;
                            rootMotionModification2.rx    = value2.x;
                            rootMotionModification2.ry    = value2.y;
                            rootMotionModification2.rz    = value2.z;
                            rootMotionModification2.rw    = value2.w;
                            list2.Add(current3.Key);
                        }
                    }
                }
            }
            foreach (object current4 in list2)
            {
                rotationModifications.Remove(current4);
            }
            List <object> list3 = new List <object>();

            foreach (KeyValuePair <object, AnimationRecording.Vector3Modification> current5 in scaleModifications)
            {
                AnimationRecording.Vector3Modification value3 = current5.Value;
                Transform transform3 = current5.Key as Transform;
                if (!(transform3 == null))
                {
                    EditorCurveBinding editorCurveBinding3 = default(EditorCurveBinding);
                    if (AnimationUtility.PropertyModificationToEditorCurveBinding(value3.last.currentValue, state.activeRootGameObject, out editorCurveBinding3) != null)
                    {
                        bool flag10 = activeRootGameObject.transform == transform3;
                        bool flag11 = flag && !flag10 && component.IsBoneTransform(transform3);
                        if (flag11)
                        {
                            Debug.LogWarning("Keyframing scale on humanoid rig is not supported!", transform3);
                            list3.Add(current5.Key);
                        }
                    }
                }
            }
            foreach (object current6 in list3)
            {
                scaleModifications.Remove(current6);
            }
            AnimationRecording.ProcessRootMotionModifications(state, ref dictionary);
        }
예제 #25
0
        private static void ProcessRotationModifications(IAnimationRecordingState state, ref Dictionary <object, AnimationRecording.RotationModification> rotationModifications)
        {
            AnimationClip activeAnimationClip  = state.activeAnimationClip;
            GameObject    activeRootGameObject = state.activeRootGameObject;

            foreach (KeyValuePair <object, AnimationRecording.RotationModification> current in rotationModifications)
            {
                AnimationRecording.RotationModification value = current.Value;
                Transform transform = current.Key as Transform;
                if (!(transform == null))
                {
                    EditorCurveBinding editorCurveBinding = default(EditorCurveBinding);
                    Type type = AnimationUtility.PropertyModificationToEditorCurveBinding(value.lastQuatModification.currentValue, state.activeRootGameObject, out editorCurveBinding);
                    if (type != null)
                    {
                        AnimationRecording.AddRotationPropertyModification(state, editorCurveBinding, value.x);
                        AnimationRecording.AddRotationPropertyModification(state, editorCurveBinding, value.y);
                        AnimationRecording.AddRotationPropertyModification(state, editorCurveBinding, value.z);
                        AnimationRecording.AddRotationPropertyModification(state, editorCurveBinding, value.w);
                        Quaternion localRotation  = transform.localRotation;
                        Quaternion localRotation2 = transform.localRotation;
                        object     obj;
                        if (AnimationRecording.ValueFromPropertyModification(value.x.previousValue, editorCurveBinding, out obj))
                        {
                            localRotation.x = (float)obj;
                        }
                        object obj2;
                        if (AnimationRecording.ValueFromPropertyModification(value.y.previousValue, editorCurveBinding, out obj2))
                        {
                            localRotation.y = (float)obj2;
                        }
                        object obj3;
                        if (AnimationRecording.ValueFromPropertyModification(value.z.previousValue, editorCurveBinding, out obj3))
                        {
                            localRotation.z = (float)obj3;
                        }
                        object obj4;
                        if (AnimationRecording.ValueFromPropertyModification(value.w.previousValue, editorCurveBinding, out obj4))
                        {
                            localRotation.w = (float)obj4;
                        }
                        if (AnimationRecording.ValueFromPropertyModification(value.x.currentValue, editorCurveBinding, out obj))
                        {
                            localRotation2.x = (float)obj;
                        }
                        if (AnimationRecording.ValueFromPropertyModification(value.y.currentValue, editorCurveBinding, out obj2))
                        {
                            localRotation2.y = (float)obj2;
                        }
                        if (AnimationRecording.ValueFromPropertyModification(value.z.currentValue, editorCurveBinding, out obj3))
                        {
                            localRotation2.z = (float)obj3;
                        }
                        if (AnimationRecording.ValueFromPropertyModification(value.w.currentValue, editorCurveBinding, out obj4))
                        {
                            localRotation2.w = (float)obj4;
                        }
                        if (value.useEuler)
                        {
                            AnimationRecording.AddRotationPropertyModification(state, editorCurveBinding, value.eulerX);
                            AnimationRecording.AddRotationPropertyModification(state, editorCurveBinding, value.eulerY);
                            AnimationRecording.AddRotationPropertyModification(state, editorCurveBinding, value.eulerZ);
                            Vector3 vector  = transform.GetLocalEulerAngles(RotationOrder.OrderZXY);
                            Vector3 vector2 = vector;
                            object  obj5;
                            if (AnimationRecording.ValueFromPropertyModification(value.eulerX.previousValue, editorCurveBinding, out obj5))
                            {
                                vector.x = (float)obj5;
                            }
                            object obj6;
                            if (AnimationRecording.ValueFromPropertyModification(value.eulerY.previousValue, editorCurveBinding, out obj6))
                            {
                                vector.y = (float)obj6;
                            }
                            object obj7;
                            if (AnimationRecording.ValueFromPropertyModification(value.eulerZ.previousValue, editorCurveBinding, out obj7))
                            {
                                vector.z = (float)obj7;
                            }
                            if (AnimationRecording.ValueFromPropertyModification(value.eulerX.currentValue, editorCurveBinding, out obj5))
                            {
                                vector2.x = (float)obj5;
                            }
                            if (AnimationRecording.ValueFromPropertyModification(value.eulerY.currentValue, editorCurveBinding, out obj6))
                            {
                                vector2.y = (float)obj6;
                            }
                            if (AnimationRecording.ValueFromPropertyModification(value.eulerZ.currentValue, editorCurveBinding, out obj7))
                            {
                                vector2.z = (float)obj7;
                            }
                            vector  = AnimationUtility.GetClosestEuler(localRotation, vector, RotationOrder.OrderZXY);
                            vector2 = AnimationUtility.GetClosestEuler(localRotation2, vector2, RotationOrder.OrderZXY);
                            AnimationRecording.AddRotationKey(state, editorCurveBinding, type, vector, vector2);
                        }
                        else
                        {
                            Vector3 localEulerAngles = transform.GetLocalEulerAngles(RotationOrder.OrderZXY);
                            Vector3 closestEuler     = AnimationUtility.GetClosestEuler(localRotation, localEulerAngles, RotationOrder.OrderZXY);
                            Vector3 closestEuler2    = AnimationUtility.GetClosestEuler(localRotation2, localEulerAngles, RotationOrder.OrderZXY);
                            AnimationRecording.AddRotationKey(state, editorCurveBinding, type, closestEuler, closestEuler2);
                        }
                    }
                }
            }
        }
 public void SaveCurve(AnimationWindowCurve curve)
 {
     Undo.RegisterCompleteObjectUndo(curve.clip, "Edit Candidate Curve");
     AnimationRecording.SaveModifiedCurve(curve, curve.clip);
 }