Beispiel #1
0
        private void SampleAnimation(SynchronizeObject data)
        {
            if (data == null || data.clip == null)
            {
                return;
            }
            data.transformPoseSave.ResetOriginalTransform();
            data.blendShapeWeightSave.ResetOriginalWeight();
            if (data.animator != null)
            {
                #region Animator
#if UNITY_2018_3_OR_NEWER
                var changedRootMotion = data.animator.applyRootMotion;
                if (changedRootMotion)
                {
                    data.animator.applyRootMotion = false;
                }
#endif
                data.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

                if (!data.animator.isInitialized)
                {
                    data.animator.Rebind();
                }
                data.clip.SampleAnimation(data.gameObject, currentTime);

                data.animator.enabled = false;  //In order to avoid the mysterious behavior where an event is called from "UnityEditor.Handles: DrawCameraImpl", it is invalid except when updating

#if UNITY_2018_3_OR_NEWER
                if (changedRootMotion)
                {
                    data.animator.applyRootMotion = true;
                }
#endif
                #endregion
            }
            else if (data.animation != null)
            {
                #region Animation
                data.clip.SampleAnimation(data.gameObject, currentTime);
                #endregion
            }
        }
        private void SampleAnimation(SynchronizeObject data)
        {
            if (data == null || data.clip == null)
            {
                return;
            }
            data.transformPoseSave.ResetOriginalTransform();
            data.blendShapeWeightSave.ResetOriginalWeight();
            if (data.animator != null)
            {
                #region Animator
#if UNITY_2018_3_OR_NEWER
                #region Playable
                if (data.m_AnimationClipPlayable.IsValid())
                {
                    data.m_AnimationClipPlayable.SetTime(currentTime);
                    if (data.m_PlayableGraph.IsValid())
                    {
#if VERYANIMATION_ANIMATIONRIGGING
                        if (data.m_RigBuilder != null)
                        {
                            data.m_RigBuilder.UpdatePreviewGraph(data.m_PlayableGraph);
                        }
#endif
                        data.m_PlayableGraph.Evaluate();
                    }
                }
                #endregion
#else
                #region Legacy
                {
#if UNITY_2018_3_OR_NEWER
                    var changedRootMotion = data.animator.applyRootMotion;
                    if (changedRootMotion)
                    {
                        data.animator.applyRootMotion = false;
                    }
#endif
                    data.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

                    if (!data.animator.isInitialized)
                    {
                        data.animator.Rebind();
                    }
                    data.clip.SampleAnimation(data.gameObject, currentTime);

                    data.animator.enabled = false;  //In order to avoid the mysterious behavior where an event is called from "UnityEditor.Handles: DrawCameraImpl", it is invalid except when updating

#if UNITY_2018_3_OR_NEWER
                    if (changedRootMotion)
                    {
                        data.animator.applyRootMotion = true;
                    }
#endif
                }
                #endregion
#endif
                #endregion
            }
            else if (data.animation != null)
            {
                #region Animation
                data.clip.SampleAnimation(data.gameObject, currentTime);
                #endregion
            }
        }