Пример #1
0
        public Handler Add(RuntimeAnimatorController controller)
        {
            m_Animator.runtimeAnimatorController = null;
            var controllerPlayable = AnimatorControllerPlayable.Create(m_Graph, controller);

            controllerPlayable.SetTime(0f);

            var index = m_AnimatorHandlers.Count;

            if (index >= m_MaxMixingCount)
            {
                throw new System.InvalidOperationException(string.Format("More than the specified count of AnimatorController have been added. (max: {0})", m_MaxMixingCount));
            }

            var Weight = 0f;

            m_AnimatorControllerMixer.ConnectInput(index, controllerPlayable, 0, Weight);

            var handler = new Handler(Type.Animator, index, Weight, OnChangeWeight, OnRemove);

            handler.SetAnimatorController(controllerPlayable);
            m_AnimatorHandlers.Add(handler);

            var target = m_PlayableOutput.GetTarget();

            if (target != null)
            {
                target.Rebind();
            }

            return(handler);
        }
Пример #2
0
        private void FetchPreviewComponents()
        {
            m_PreviewComponents = new List <IAnimationWindowPreview>();

            var animator = m_Output.GetTarget();

            if (animator == null)
            {
                return;
            }

            var gameObject = animator.gameObject;

            m_PreviewComponents.AddRange(gameObject.GetComponents <IAnimationWindowPreview>());
        }
Пример #3
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
        }