Ejemplo n.º 1
0
        void FindMixers()
        {
            m_Mixers.Clear();
            m_PoseMixer       = AnimationLayerMixerPlayable.Null;
            m_LayerMixer      = AnimationLayerMixerPlayable.Null;
            m_MotionXPlayable = AnimationMotionXToDeltaPlayable.Null;

            var playable   = m_Output.GetSourcePlayable();
            var outputPort = m_Output.GetSourceOutputPort();

            if (!playable.IsValid() || outputPort < 0 || outputPort >= playable.GetInputCount())
            {
                return;
            }

            var mixer = FindFirstAnimationPlayable(playable.GetInput(outputPort));

            Playable motionXPlayable = mixer;

            if (motionXPlayable.IsPlayableOfType <AnimationMotionXToDeltaPlayable>())
            {
                m_MotionXPlayable = (AnimationMotionXToDeltaPlayable)motionXPlayable;
                mixer             = m_MotionXPlayable.GetInput(0);
            }

#if UNITY_EDITOR
            // Default pose mixer
            if (!Application.isPlaying)
            {
                if (mixer.IsValid() && mixer.IsPlayableOfType <AnimationLayerMixerPlayable>())
                {
                    m_PoseMixer = (AnimationLayerMixerPlayable)mixer;
                    mixer       = m_PoseMixer.GetInput(1);
                }
            }
#endif

            // Track mixer
            if (mixer.IsValid() && mixer.IsPlayableOfType <AnimationLayerMixerPlayable>())
            {
                m_LayerMixer = (AnimationLayerMixerPlayable)mixer;
            }

            if (!m_LayerMixer.IsValid())
            {
                return;
            }

            var count = m_LayerMixer.GetInputCount();
            for (var i = 0; i < count; i++)
            {
                FindMixers(m_LayerMixer, i, m_LayerMixer.GetInput(i));
            }
        }
        void FindMixers()
        {
            m_Mixers.Clear();
            m_PoseMixer       = AnimationMixerPlayable.Null;
            m_LayerMixer      = AnimationLayerMixerPlayable.Null;
            m_MotionXPlayable = AnimationMotionXToDeltaPlayable.Null;

            var playable   = m_Output.GetSourcePlayable();
            var outputPort = m_Output.GetSourceOutputPort();

            if (!playable.IsValid() || outputPort < 0 || outputPort >= playable.GetInputCount())
            {
                return;
            }

            var mixer = FindFirstAnimationPlayable(playable.GetInput(outputPort));

            Playable motionXPlayable = mixer;

            if (motionXPlayable.IsPlayableOfType <AnimationMotionXToDeltaPlayable>())
            {
                m_MotionXPlayable = (AnimationMotionXToDeltaPlayable)motionXPlayable;
                mixer             = m_MotionXPlayable.GetInput(0);
            }

            if (mixer.IsValid() && mixer.IsPlayableOfType <AnimationMixerPlayable>())
            {
                m_PoseMixer = (AnimationMixerPlayable)mixer;
                Playable layerMixer = m_PoseMixer.GetInput(0);

                if (layerMixer.IsValid() && layerMixer.IsPlayableOfType <AnimationLayerMixerPlayable>())
                {
                    m_LayerMixer = (AnimationLayerMixerPlayable)layerMixer;
                }
            }
            else if (mixer.IsValid() && mixer.IsPlayableOfType <AnimationLayerMixerPlayable>())
            {
                m_LayerMixer = (AnimationLayerMixerPlayable)mixer;
            }


            if (!m_LayerMixer.IsValid())
            {
                return;
            }

            var count = m_LayerMixer.GetInputCount();

            for (var i = 0; i < count; i++)
            {
                FindMixers(m_LayerMixer, i, m_LayerMixer.GetInput(i));
            }
        }