Exemple #1
0
        public IEnumerator OneClip_NoTransition_Infinite()
        {
            var AnimatorPlayableGameObject = new AnimatorPlayableGameObject();

            float clipTime = 0.25f;

            AnimatorPlayableGameObject.PlaySequencedAnimation(0, new SequencedAnimationInput()
            {
                isInfinite           = true,
                BeginTransitionTime  = 0f,
                EndTransitionTime    = 0f,
                UniqueAnimationClips = new List <UniqueAnimationClipInput>()
                {
                    new UniqueAnimationClipInput()
                    {
                        AnimationClip = CreateClip(clipTime)
                    }
                }
            });
            yield return(null);

            yield return(new WaitForSeconds(clipTime));

            var SequencedAnimationLayer = AnimatorPlayableGameObject.AnimatorPlayableObject.AllAnimationLayersCurrentlyPlaying[0] as SequencedAnimationLayer;

            Assert.IsTrue(AnimatorPlayableGameObject.AnimatorPlayableObject.AllAnimationLayersCurrentlyPlaying.Count == 1);
            Assert.IsTrue(SequencedAnimationLayer.AnimationMixerPlayable.GetInputCount() == 1);
            Assert.IsTrue(SequencedAnimationLayer.AnimationMixerPlayable.GetInputWeight(0) == 1f);
            yield return(null);
        }
Exemple #2
0
        public IEnumerator LayersSorted()
        {
            var AnimatorPlayableGameObject = new AnimatorPlayableGameObject();

            yield return(null);

            AnimatorPlayableGameObject.PlaySequencedAnimation(4, new SequencedAnimationInput()
            {
                isInfinite = true, UniqueAnimationClips = new List <UniqueAnimationClipInput>()
                {
                    new UniqueAnimationClipInput()
                    {
                        AnimationClip = CreateClip(1f)
                    }
                }
            });
            yield return(null);

            Assert.IsTrue(AnimatorPlayableGameObject.AnimatorPlayableObject.AllAnimationLayersCurrentlyPlaying[4].Inputhandler == 0);

            AnimatorPlayableGameObject.PlaySequencedAnimation(1, new SequencedAnimationInput()
            {
                isInfinite = true, UniqueAnimationClips = new List <UniqueAnimationClipInput>()
                {
                    new UniqueAnimationClipInput()
                    {
                        AnimationClip = CreateClip(1f)
                    }
                }
            });
            yield return(null);

            Assert.IsTrue(AnimatorPlayableGameObject.AnimatorPlayableObject.AllAnimationLayersCurrentlyPlaying[1].Inputhandler == 0);
            Assert.IsTrue(AnimatorPlayableGameObject.AnimatorPlayableObject.AllAnimationLayersCurrentlyPlaying[4].Inputhandler == 1);

            AnimatorPlayableGameObject.PlaySequencedAnimation(2, new SequencedAnimationInput()
            {
                isInfinite = true, UniqueAnimationClips = new List <UniqueAnimationClipInput>()
                {
                    new UniqueAnimationClipInput()
                    {
                        AnimationClip = CreateClip(1f)
                    }
                }
            });
            yield return(null);

            Assert.IsTrue(AnimatorPlayableGameObject.AnimatorPlayableObject.AllAnimationLayersCurrentlyPlaying[1].Inputhandler == 0);
            Assert.IsTrue(AnimatorPlayableGameObject.AnimatorPlayableObject.AllAnimationLayersCurrentlyPlaying[2].Inputhandler == 1);
            Assert.IsTrue(AnimatorPlayableGameObject.AnimatorPlayableObject.AllAnimationLayersCurrentlyPlaying[4].Inputhandler == 2);
        }
Exemple #3
0
        public IEnumerator OneClip_StartTransition()
        {
            var AnimatorPlayableGameObject = new AnimatorPlayableGameObject();

            float beginTransitionTime = 0.0625f;
            float clipTime            = 0.25f;

            AnimatorPlayableGameObject.PlaySequencedAnimation(0, new SequencedAnimationInput()
            {
                isInfinite           = false,
                BeginTransitionTime  = beginTransitionTime,
                EndTransitionTime    = 0f,
                UniqueAnimationClips = new List <UniqueAnimationClipInput>()
                {
                    new UniqueAnimationClipInput()
                    {
                        AnimationClip = CreateClip(clipTime)
                    }
                }
            });
            yield return(null);

            Assert.IsTrue(AnimatorPlayableGameObject.AnimatorPlayableObject.AnimationLayerMixerPlayable.GetInputCount() == 1);
            Assert.IsTrue(AnimatorPlayableGameObject.AnimatorPlayableObject.AnimationLayerMixerPlayable.GetInputWeight(0) == 0f);
            var SequencedAnimationLayer = AnimatorPlayableGameObject.AnimatorPlayableObject.AllAnimationLayersCurrentlyPlaying[0] as SequencedAnimationLayer;

            // The first animation is weighter to 1 bu paused -> this allows the layer to transition to the first frame
            Assert.IsTrue(SequencedAnimationLayer.AnimationMixerPlayable.GetInputWeight(0) == 1f);
            Assert.IsTrue(SequencedAnimationLayer.AssociatedAnimationClipsPlayable[0].GetTime() == 0f);
            Assert.IsTrue(SequencedAnimationLayer.AssociatedAnimationClipsPlayable[0].GetPlayState() == PlayState.Paused);
            ////* *////


            yield return(new WaitForSeconds(beginTransitionTime * 0.5f));

            Assert.IsTrue(AnimatorPlayableGameObject.AnimatorPlayableObject.AnimationLayerMixerPlayable.GetInputWeight(0) >= 0.5f &&
                          AnimatorPlayableGameObject.AnimatorPlayableObject.AnimationLayerMixerPlayable.GetInputWeight(0) < 0.9f);
            yield return(new WaitWhile(() => AnimatorPlayableGameObject.AnimatorPlayableObject.AnimationLayerMixerPlayable.GetInputWeight(0) < 1f));

            Assert.IsTrue(AnimatorPlayableGameObject.AnimatorPlayableObject.AnimationLayerMixerPlayable.GetInputWeight(0) == 1f);
            Assert.IsTrue(SequencedAnimationLayer.AssociatedAnimationClipsPlayable[0].GetPlayState() == PlayState.Playing);
            yield return(new WaitForSeconds(clipTime));

            Assert.IsTrue(AnimatorPlayableGameObject.AnimatorPlayableObject.AllAnimationLayersCurrentlyPlaying.Count == 0);
            Assert.IsTrue(AnimatorPlayableGameObject.AnimatorPlayableObject.AnimationLayerMixerPlayable.GetInputCount() == 0);
        }
Exemple #4
0
        public IEnumerator Blended_ThreeClip()
        {
            var AnimatorPlayableGameObject = new AnimatorPlayableGameObject();

            float weightSetted = 0f;
            float clipTime     = 0.25f;

            AnimatorPlayableGameObject.PlayBlendedAnimation(0, new BlendedAnimationInput()
            {
                BlendedAnimationClips = new List <BlendedAnimationClipInput>()
                {
                    new BlendedAnimationClipInput()
                    {
                        AnimationClip = CreateClip(clipTime),
                        WeightTime    = 0f
                    },
                    new BlendedAnimationClipInput()
                    {
                        AnimationClip = CreateClip(clipTime),
                        WeightTime    = 0.5f
                    },
                    new BlendedAnimationClipInput()
                    {
                        AnimationClip = CreateClip(clipTime),
                        WeightTime    = 1f
                    }
                }
            }, () => weightSetted);

            yield return(null);

            var BlendedAnimationLayer = AnimatorPlayableGameObject.AnimatorPlayableObject.AllAnimationLayersCurrentlyPlaying[0] as BlendedAnimationLayer;

            Assert.IsTrue(BlendedAnimationLayer.AnimationMixerPlayable.GetInputCount() == 3);
            Assert.IsTrue(BlendedAnimationLayer.AnimationMixerPlayable.GetInputWeight(0) == 1f);
            Assert.IsTrue(BlendedAnimationLayer.AnimationMixerPlayable.GetInputWeight(1) == 0f);
            Assert.IsTrue(BlendedAnimationLayer.AnimationMixerPlayable.GetInputWeight(2) == 0f);

            weightSetted = 0.25f;
            yield return(null);

            Assert.IsTrue(BlendedAnimationLayer.AnimationMixerPlayable.GetInputWeight(0) == 0.5f);
            Assert.IsTrue(BlendedAnimationLayer.AnimationMixerPlayable.GetInputWeight(1) == 0.5f);
            Assert.IsTrue(BlendedAnimationLayer.AnimationMixerPlayable.GetInputWeight(2) == 0f);

            weightSetted = 0.5f;
            yield return(null);

            Assert.IsTrue(BlendedAnimationLayer.AnimationMixerPlayable.GetInputWeight(0) == 0f);
            Assert.IsTrue(BlendedAnimationLayer.AnimationMixerPlayable.GetInputWeight(1) == 1f);
            Assert.IsTrue(BlendedAnimationLayer.AnimationMixerPlayable.GetInputWeight(2) == 0f);

            weightSetted = 0.75f;
            yield return(null);

            Assert.IsTrue(BlendedAnimationLayer.AnimationMixerPlayable.GetInputWeight(0) == 0f);
            Assert.IsTrue(BlendedAnimationLayer.AnimationMixerPlayable.GetInputWeight(1) == 0.5f);
            Assert.IsTrue(BlendedAnimationLayer.AnimationMixerPlayable.GetInputWeight(2) == 0.5f);

            weightSetted = 1f;
            yield return(null);

            Assert.IsTrue(BlendedAnimationLayer.AnimationMixerPlayable.GetInputWeight(0) == 0f);
            Assert.IsTrue(BlendedAnimationLayer.AnimationMixerPlayable.GetInputWeight(1) == 0f);
            Assert.IsTrue(BlendedAnimationLayer.AnimationMixerPlayable.GetInputWeight(2) == 1f);
        }
Exemple #5
0
        public IEnumerator ThreeClip_InnterBlending_InnerDelay()
        {
            var AnimatorPlayableGameObject = new AnimatorPlayableGameObject();

            float transitionTime = 0.0625f;
            float clipTime       = 0.25f;

            AnimatorPlayableGameObject.PlaySequencedAnimation(0, new SequencedAnimationInput()
            {
                isInfinite           = false,
                BeginTransitionTime  = 0f,
                EndTransitionTime    = 0f,
                UniqueAnimationClips = new List <UniqueAnimationClipInput>()
                {
                    new UniqueAnimationClipInput()
                    {
                        AnimationClip      = CreateClip(clipTime),
                        TransitionBlending = new LinearBlending()
                        {
                            EndTransitionTime = transitionTime
                        }
                    },
                    new UniqueAnimationClipInput()
                    {
                        AnimationClip      = CreateClip(clipTime),
                        TransitionBlending = new LinearBlending()
                        {
                            EndTransitionTime = transitionTime,
                            EndClipDelay      = transitionTime
                        }
                    },
                    new UniqueAnimationClipInput()
                    {
                        AnimationClip      = CreateClip(clipTime),
                        TransitionBlending = new LinearBlending()
                        {
                            EndTransitionTime = transitionTime
                        }
                    }
                }
            });
            yield return(null);

            var SequencedAnimationLayer = AnimatorPlayableGameObject.AnimatorPlayableObject.AllAnimationLayersCurrentlyPlaying[0] as SequencedAnimationLayer;

            //Only the first clip has weight
            Assert.IsTrue(SequencedAnimationLayer.AnimationMixerPlayable.GetInputWeight(0) == 1f);
            Assert.IsTrue(SequencedAnimationLayer.AssociatedAnimationClipsPlayable[0].GetPlayState() == PlayState.Playing);

            Assert.IsTrue(SequencedAnimationLayer.AnimationMixerPlayable.GetInputWeight(1) == 0f);
            Assert.IsTrue(SequencedAnimationLayer.AssociatedAnimationClipsPlayable[1].GetPlayState() == PlayState.Paused);

            Assert.IsTrue(SequencedAnimationLayer.AnimationMixerPlayable.GetInputWeight(2) == 0f);
            Assert.IsTrue(SequencedAnimationLayer.AssociatedAnimationClipsPlayable[2].GetPlayState() == PlayState.Paused);

            yield return(new WaitForSeconds(clipTime - transitionTime));

            Assert.IsTrue(SequencedAnimationLayer.AnimationMixerPlayable.GetInputWeight(0) < 1f);
            Assert.IsTrue(SequencedAnimationLayer.AssociatedAnimationClipsPlayable[0].GetPlayState() == PlayState.Playing);

            Assert.IsTrue(SequencedAnimationLayer.AnimationMixerPlayable.GetInputWeight(1) > 0f);
            Assert.IsTrue(SequencedAnimationLayer.AssociatedAnimationClipsPlayable[1].GetPlayState() == PlayState.Playing);

            Assert.IsTrue(SequencedAnimationLayer.AnimationMixerPlayable.GetInputWeight(2) == 0f);
            Assert.IsTrue(SequencedAnimationLayer.AssociatedAnimationClipsPlayable[2].GetPlayState() == PlayState.Paused);

            yield return(new WaitForSeconds(transitionTime));

            Assert.IsTrue(SequencedAnimationLayer.AnimationMixerPlayable.GetInputWeight(0) == 0f);
            Assert.IsTrue(SequencedAnimationLayer.AssociatedAnimationClipsPlayable[0].GetPlayState() == PlayState.Paused);

            Assert.IsTrue(SequencedAnimationLayer.AnimationMixerPlayable.GetInputWeight(1) == 1f);
            Assert.IsTrue(SequencedAnimationLayer.AssociatedAnimationClipsPlayable[1].GetPlayState() == PlayState.Playing);

            Assert.IsTrue(SequencedAnimationLayer.AnimationMixerPlayable.GetInputWeight(2) == 0f);
            Assert.IsTrue(SequencedAnimationLayer.AssociatedAnimationClipsPlayable[2].GetPlayState() == PlayState.Paused);

            yield return(new WaitForSeconds(clipTime - transitionTime));

            Assert.IsTrue(SequencedAnimationLayer.AnimationMixerPlayable.GetInputWeight(0) == 0f);
            Assert.IsTrue(SequencedAnimationLayer.AssociatedAnimationClipsPlayable[0].GetPlayState() == PlayState.Paused);

            Assert.IsTrue(SequencedAnimationLayer.AnimationMixerPlayable.GetInputWeight(1) < 1f);
            Assert.IsTrue(SequencedAnimationLayer.AssociatedAnimationClipsPlayable[1].GetPlayState() == PlayState.Playing);

            Assert.IsTrue(SequencedAnimationLayer.AnimationMixerPlayable.GetInputWeight(2) > 0f);
            Assert.IsTrue(SequencedAnimationLayer.AssociatedAnimationClipsPlayable[2].GetPlayState() == PlayState.Playing);

            yield return(new WaitForSeconds(transitionTime));

            Assert.IsTrue(SequencedAnimationLayer.AnimationMixerPlayable.GetInputWeight(0) == 0f);
            Assert.IsTrue(SequencedAnimationLayer.AssociatedAnimationClipsPlayable[0].GetPlayState() == PlayState.Paused);

            Assert.IsTrue(SequencedAnimationLayer.AnimationMixerPlayable.GetInputWeight(1) == 0f);
            Assert.IsTrue(SequencedAnimationLayer.AssociatedAnimationClipsPlayable[1].GetPlayState() == PlayState.Paused);

            Assert.IsTrue(SequencedAnimationLayer.AnimationMixerPlayable.GetInputWeight(2) == 1f);
            Assert.IsTrue(SequencedAnimationLayer.AssociatedAnimationClipsPlayable[2].GetPlayState() == PlayState.Playing);
        }