Beispiel #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);
                }
            }
        }
Beispiel #2
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);
        }