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();
            }
Ejemplo n.º 2
0
        private void DestroyController()
        {
#if UNITY_2019_1_OR_NEWER
#if VERYANIMATION_ANIMATIONRIGGING
            if (m_RigBuilder != null)
            {
                m_RigBuilder.StopPreview();
                m_RigBuilder = null;
            }
            if (m_VARigBuilder != null)
            {
                m_VARigBuilder.StopPreview();
                m_VARigBuilder = null;
            }
#endif
            if (m_PlayableGraph.IsValid())
            {
                m_PlayableGraph.Destroy();
            }
#else
            if (instance != null && animator != null)
            {
                UnityEditor.Animations.AnimatorController.SetAnimatorController(animator, null);
            }
            if (m_Controller != null)
            {
                UnityEditor.Animations.AnimatorController.DestroyImmediate(m_Controller);
            }
            if (m_StateMachine != null)
            {
                AnimatorStateMachine.DestroyImmediate(m_StateMachine);
            }
            if (m_State != null)
            {
                AnimatorState.DestroyImmediate(m_State);
            }
            m_Controller   = null;
            m_StateMachine = null;
            m_State        = null;
#endif
        }