public void Connect(int index, Playable timeline)
 {
     if (!Animation.IsNull() && Animation.IsValid())
     {
         Animation.ConnectInput(index, timeline, 0);
     }
     if (!Audio.IsNull() && Audio.IsValid())
     {
         Audio.ConnectInput(index, timeline, 1);
     }
 }
Ejemplo n.º 2
0
 private void Update()
 {
     if (nowPlayAnimation == null)
     {
         if (mixer.IsValid())
         {
             mixer.Destroy();
         }
         _beforeNowPlayClip = null;
     }
     else if (_beforeNowPlayClip != nowPlayAnimation)
     {
         SetPlayAnimation(nowPlayAnimation, frameSpeed, changeFrameNow);
     }
     SetNextAnimationPlayable();
     if (playableGraph.IsValid() && mixer.IsValid())
     {
         if (frameSpeed <= 0)
         {
             return;
         }
         if (changeWeightFrame > 0)
         {
             mixer.SetInputWeight(0, (1.0f - num) - ((1.0f) - (((float)_nowChangeFrame) / ((float)changeWeightFrame))));
             mixer.SetInputWeight(1, num + ((1.0f) - (((float)_nowChangeFrame) / ((float)changeWeightFrame))));
             if (_nowChangeFrame >= changeWeightFrame)
             {
                 changeWeightFrame = 0;
                 _nowChangeFrame   = 0;
             }
             _nowChangeFrame++;
         }
         else
         {
             mixer.SetInputWeight(0, (1.0f - num));
             mixer.SetInputWeight(1, num);
         }
         playableGraph.Evaluate((1.0f / nowPlayAnimation.frameRate) * frameSpeed);
         nowFrame = (int)(((float)mixer.GetTime() * nowPlayAnimation.frameRate) * frameSpeed);
         //ループ
         if (nowFrame >= (nowPlayAnimation.length * nowPlayAnimation.frameRate * frameSpeed) && nowPlayAnimation.isLooping)
         {
             mixer.SetTime(0);
             _nowPlayAnimation.SetTime(0);
             if (_beforePlayAnimation.IsValid())
             {
                 _beforePlayAnimation.SetTime(0);
             }
         }
     }
 }
        //===========================================================================================

        /**
         *  @brief
         *
         *********************************************************************************************/
        public void EndPreviewLocal()
        {
            if (!m_previewActive)
            {
                return;
            }

            AnimationMixerPlayable mixer = MxMPreviewScene.Mixer;

            if (mixer.IsValid())
            {
                for (int i = 0; i < mixer.GetInputCount(); ++i)
                {
                    var clipPlayable = mixer.GetInput(0);

                    if (clipPlayable.IsValid())
                    {
                        mixer.DisconnectInput(0);
                        clipPlayable.Destroy();
                    }
                }
            }

            m_previewActive     = false;
            m_previewBlendSpace = null;
        }
Ejemplo n.º 4
0
        public bool IsPlaying()
        {
            if (!mixer.IsValid() || !currentPlayable.IsValid())
            {
                return(false);
            }
            var clip = currentPlayable.GetAnimationClip();

            if (!clip.isLooping)
            {
                return(clip.length >= currentPlayable.GetTime());
            }
            var state = currentPlayable.GetPlayState();

            return(state == PlayState.Playing);
        }
 //次のアニメーションをセットするときに呼び出す
 public void SetPlayAnimation(AnimationClip clip, float speed, int weightFrame = 0)
 {
     setClip           = clip;
     changeWeightFrame = weightFrame;
     animationSpeed    = speed;
     frameCount        = 0;
     if (playableGraph.IsValid() && mixer.IsValid())
     {
         beforeClipTime = nowClipPlayable.GetTime();
         mixer.SetTime(0);
         nowClipPlayable.SetTime(0);
         if (beforeClipPlayable.IsValid())
         {
             beforeClipPlayable.SetTime(0);
         }
     }
 }
Ejemplo n.º 6
0
        private void Update()
        {
            if (Input.GetKeyDown(KeyCode.Space))
            {
                animator.playableGraph.Play();
            }

            if (weightMixer.IsValid())
            {
                weightMixer.SetInputWeight(1, slider);
                weightMixer.SetInputWeight(0, 1 - slider);
            }
        }
Ejemplo n.º 7
0
    void Update()
    {
        if (!mixer.IsValid() || Speed == 0)
        {
            return;
        }
        var cWeight = mixer.GetInputWeight(0);

        if (cWeight < 1)
        {
            cWeight = Mathf.Lerp(0, 1, (Time.time - changeTime) / blendTime);
            mixer.SetInputWeight(0, cWeight);
            mixer.SetInputWeight(1, 1 - cWeight);
        }
        graph.Evaluate(Time.deltaTime * Speed);
    }