コード例 #1
0
        public void Evaluate()
        {
            m_Output.SetWeight(1);
            for (int i = 0; i < m_Mixers.Count; i++)
            {
                var   mixInfo = m_Mixers[i];
                float weight  = mixInfo.modulate ? mixInfo.parentMixer.GetInputWeight(mixInfo.port) : 1.0f;
                mixInfo.parentMixer.SetInputWeight(mixInfo.port, weight * WeightUtility.NormalizeMixer(mixInfo.mixer));
            }

            float normalizedWeight = WeightUtility.NormalizeMixer(m_LayerMixer);

            var animator = m_Output.GetTarget();

            if (animator == null)
            {
                return;
            }

#if UNITY_EDITOR
            // AnimationMotionXToDeltaPlayable must blend with default values when previewing tracks with absolute root motion.
            bool blendMotionX = !Application.isPlaying && m_MotionXPlayable.IsValid() && m_MotionXPlayable.IsAbsoluteMotion();

            if (blendMotionX)
            {
                if (!m_PoseMixer.Equals(AnimationLayerMixerPlayable.Null))
                {
                    m_PoseMixer.SetInputWeight(0, 1.0f);
                    m_PoseMixer.SetInputWeight(1, normalizedWeight);
                }
            }
            else
            {
                if (!m_PoseMixer.Equals(AnimationLayerMixerPlayable.Null))
                {
                    m_PoseMixer.SetInputWeight(0, 1.0f);
                    m_PoseMixer.SetInputWeight(1, 1.0f);
                }

                m_Output.SetWeight(normalizedWeight);
            }
#else
            m_Output.SetWeight(normalizedWeight);
#endif
        }