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