Exemple #1
0
        void Restore()
        {
            if (animator != null)
            {
                animator.runtimeAnimatorController = wasController;
                animator.applyRootMotion           = wasRootMotion;
                animator.cullingMode = wasCullingMode;
                animator.enabled     = wasEnabled;
            }

#if UNITY_2017_1_OR_NEWER
            if (graph.IsValid())
            {
                graph.Destroy();
            }
#elif UNITY_5_6_OR_NEWER
            if (graph.IsValid())
            {
                graph.Destroy();
            }
#else
            mixerPlayable.Destroy();
            if (Application.isPlaying && animator.runtimeAnimatorController != null)
            {
                RestoreAnimatorInfo();
            }
#endif
        }
Exemple #2
0
        /************************************************************************************************************************/
#endif
        /************************************************************************************************************************/

        /// <summary>
        /// Called by Unity when this component is first created.
        /// <para></para>
        /// Initialises everything needed to play the <see cref="Clip"/>.
        /// </summary>
        private void Awake()
        {
            if (_Clip == null || _Animator == null)
            {
                return;
            }

            if (_Graph.IsValid())
            {
                _Graph.Destroy();
            }

            _Playable = AnimationPlayableUtilities.PlayClip(_Animator, _Clip, out _Graph);

            _Playable.SetSpeed(_Speed);

            if (!_FootIK)
            {
                _Playable.SetApplyFootIK(false);
            }

            if (!_Clip.isLooping)
            {
                _Playable.SetDuration(_Clip.length);
            }
        }
Exemple #3
0
 void ResetAnim()
 {
     m_Graph.Destroy();
     m_Handles.Dispose();
     m_BoneWeights.Dispose();
     OnEnable();
 }
Exemple #4
0
        public void StopPreviewing()
        {
            IsShowingPreview = false;

            previewGraph.Destroy();

            animationPlayer.gameObject.GetComponent <Animator>().Update(0f);
        }
 void OnApplicationQuit()
 {
     if (haveGraph)
     {
         graph.Destroy();
     }
     haveGraph = false;
 }
Exemple #6
0
 public void PlayClip(AnimationClip c, bool randomStart)
 {
     if (playableGraph.IsValid())
     {
         playableGraph.Destroy();
     }
     clip = c;
     Play(randomStart);
 }
Exemple #7
0
    private void Reset()
    {
        if (m_Graph.IsValid())
        {
            m_Graph.Destroy();
        }

        m_Initialized = false;
    }
 private void OnDestroy()
 {
     if (graph.IsValid())
     {
         graph.Destroy();
     }
 }
Exemple #9
0
 void OnDisable()
 {
     if (playableGraph.IsValid())
     {
         playableGraph.Destroy();
     }
 }
 private void OnDisable()
 {
     if (m_graph.IsValid())
     {
         m_graph.Destroy();
     }
 }
Exemple #11
0
 public override void OnPlayableDestroy(Playable playable)
 {
     if (playableGraph.IsValid())
     {
         playableGraph.Destroy();
     }
 }
Exemple #12
0
 void OnDisable()
 {
     m_Graph.Destroy();
     emptyGraph.Destroy();
     m_Handles.Dispose();
     m_BoneWeights.Dispose();
 }
Exemple #13
0
 public void Release()
 {
     if (_playableGraph.IsValid())
     {
         _playableGraph.Destroy();
     }
 }
            public void Release()
            {
#if UNITY_2018_3_OR_NEWER
#if VERYANIMATION_ANIMATIONRIGGING
                if (m_RigBuilder != null)
                {
                    m_RigBuilder.StopPreview();
                }
                if (m_VARigBuilder != null)
                {
                    m_VARigBuilder.StopPreview();
                }
#endif
                if (m_PlayableGraph.IsValid())
                {
                    m_PlayableGraph.Destroy();
                }
#else
                if (animator != null)
                {
                    animator.enabled = true;   //In order to avoid the mysterious behavior where an event is called from "UnityEditor.Handles: DrawCameraImpl", it is invalid except when updating
                }
#endif
                #region Save
                if (animator != null)
                {
                    animator.fireEvents = saveFireEvents;
                }
                #endregion

                animationClipValueSave.ResetValue();
                transformPoseSave.ResetOriginalTransform();
                blendShapeWeightSave.ResetOriginalWeight();
            }
 /// <summary>
 /// This function is called when the MonoBehaviour will be destroyed.
 /// </summary>
 void OnDestroy()
 {
     if (_playableGraph.IsValid())
     {
         _playableGraph.Destroy();
     }
 }
 public void Dispose()
 {
     if (m_Graph.IsValid())
     {
         m_Graph.Destroy();
     }
 }
Exemple #17
0
    void OnDisable()

    {
        // Destroys all Playables and Outputs created by the graph.

        playableGraph.Destroy();
    }
Exemple #18
0
 public void OnDestroy()
 {
     if (graph.IsValid())
     {
         graph.Destroy();
     }
 }
Exemple #19
0
 protected void Cleanup()
 {
     if (graph.IsValid())
     {
         graph.Stop();
     }
     if (mixerCoroutine != null)
     {
         StopCoroutine(mixerCoroutine);
         mixerCoroutine = null;
     }
     if (currentPlayable.IsValid())
     {
         currentPlayable.Destroy();
     }
     if (previousPlayable.IsValid())
     {
         previousPlayable.Destroy();
     }
     if (mixer.IsValid())
     {
         mixer.Destroy();
     }
     if (graph.IsValid())
     {
         graph.Destroy();
     }
 }
Exemple #20
0
 private void OnDestroy()
 {
     if (playableGraph.IsValid())
     {
         playableGraph.Destroy();
     }
 }
Exemple #21
0
        /// <summary>
        /// Use animation Playables API to control keyed values, blended between the first frame of 2 animation clips.
        /// </summary>
        /// <param name="valueForAdaptationCurve">A value to evaluate into adaptation curve producing a real blend value for 2 clips.</param>
        /// <param name="animator">The control target for animation playables. The clips used must be able to control the keyed fields traveling down from this animator component.</param>
        public void Adapt(float valueForAdaptationCurve, Animator animator)
        {
            if (!Adaptable)
            {
                return;
            }

            float blend = adaptationCurve.Evaluate(valueForAdaptationCurve);

            //Connect up a playable graph, evaluate once, then we're done with them.
            PlayableGraph pg = PlayableGraph.Create("AdaptationGraph");

            pg.SetTimeUpdateMode(DirectorUpdateMode.Manual);

            var mixer = AnimationMixerPlayable.Create(pg, 2, normalizeWeights: true);

            //Not sure if the mixer should be "cross fade" like this, or should we do 0~1 weight over 1 weight?
            //But I think that's for AnimationLayerMixerPlayable ?
            mixer.SetInputWeight(inputIndex: 0, weight: 1 - blend);
            mixer.SetInputWeight(inputIndex: 1, weight: blend);


            var normalStateAcp       = AnimationClipPlayable.Create(pg, normalState);
            var fullyAdaptedStateAcp = AnimationClipPlayable.Create(pg, fullyAdaptedState);

            pg.Connect(normalStateAcp, sourceOutputPort: 0, mixer, destinationInputPort: 0);
            pg.Connect(fullyAdaptedStateAcp, sourceOutputPort: 0, mixer, destinationInputPort: 1);

            var output = AnimationPlayableOutput.Create(pg, "AdaptationGraphOutput", animator);

            output.SetSourcePlayable(mixer);

            pg.Evaluate();
            pg.Destroy();
        }
Exemple #22
0
 void OnDestroy()
 {
     if (_graph.IsValid())
     {
         _graph.Destroy();
     }
 }
Exemple #23
0
 public void OnDestroy()
 {
     if (m_Graph.IsValid())
     {
         m_Graph.Destroy();
     }
 }
        private void OnDestroy()
        {
            #if UNITY_EDITOR
            GraphVisualizerClient.Hide(_graph);
            #endif

            _graph.Destroy();
        }
Exemple #25
0
 void OnDisable()
 {
     if (m_PlayableGraph.IsValid())
     {
         m_AnimGraph.Shutdown();
         m_PlayableGraph.Destroy();
     }
 }
 protected virtual void OnDestroy()
 {
     if (_graph.IsValid())
     {
         _graph.Stop();
         _graph.Destroy();
     }
 }
 /// <summary>
 /// Called by Unity.
 /// </summary>
 private void OnDisable()
 {
     // Destroy _playableGrap.
     if (_playableGrap.IsValid())
     {
         _playableGrap.Destroy();
     }
 }
 void OnDestroy()
 {
     // Destroys all Playables and Outputs created by the graph.
     if (playableGraph.IsValid())
     {
         playableGraph.Destroy();
     }
 }
        //...
        protected override void OnExit()
        {
            if (isMasterTrack)
            {
                animator.applyRootMotion = wasRootMotion;
                animator.cullingMode     = wasCullingMode;
                if (graph.IsValid())
                {
                    graph.Destroy();
                }

                if (useRootMotion)
                {
                    ApplyBakedRootMotion(endTime - startTime);
                }
            }
        }
Exemple #30
0
 void DisposeGraph()
 {
     if (g.IsValid())
     {
         g.Stop();
         g.Destroy();
     }
 }