//============================================================================================

        /**
         *  @brief Starts pose debugging in editor and creates the playable graph.
         *
         *********************************************************************************************/
        public void StartPoseDebug(int a_animDataId)
        {
            if (m_animData.Length > 0 && a_animDataId < m_animData.Length)
            {
                CurrentAnimData = m_animData[a_animDataId];
            }

            if (CurrentAnimData != null)
            {
                p_animator = GetComponent <Animator>();

                m_animationStates = new MxMPlayableState[1];

                if (p_animator)
                {
                    MxMPlayableGraph = PlayableGraph.Create();
                    MxMPlayableGraph.SetTimeUpdateMode(DirectorUpdateMode.Manual);

                    var playableOutput = AnimationPlayableOutput.Create(MxMPlayableGraph, "Animation", p_animator);
                    m_animationMixer = AnimationMixerPlayable.Create(MxMPlayableGraph, 1, true);
                    playableOutput.SetSourcePlayable(m_animationMixer);
                    m_animationMixer.SetInputWeight(0, 1f);

                    basePosition = transform.position;
                    baseRotation = transform.rotation;

                    m_debugPosesActive = true;
                }
                else
                {
                    m_debugPoses       = false;
                    m_debugPosesActive = false;
                }
            }
        }
        //============================================================================================

        /**
         *  @brief Updates the pose debug data for the editor pose debugging functionality.
         *
         *********************************************************************************************/
        public void UpdatePoseDebug()
        {
            var playable = m_animationMixer.GetInput(0);

            if (playable.IsValid())
            {
                MxMPlayableGraph.DestroySubgraph(playable);
            }

            transform.SetPositionAndRotation(basePosition, baseRotation);

            SetupPoseInSlot(ref CurrentAnimData.Poses[m_debugPoseId], 0, 1f);
            m_animationMixer.SetInputWeight(0, 1f);
            MxMPlayableGraph.Evaluate(0f);

            SceneView.RepaintAll();
        }
        //============================================================================================

        /**
         *  @brief Stops pose debugging and destroys the playable graph
         *
         *********************************************************************************************/
        public void StopPoseDebug()
        {
            if (!m_debugPosesActive)
            {
                return;
            }

            if (m_animData.Length > 0 && m_animData[0] != null)
            {
                CurrentAnimData = m_animData[0];
            }

            if (CurrentAnimData != null)
            {
                m_debugPosesActive = false;

                PoseData      pose = CurrentAnimData.Poses[0];
                AnimationClip clip = CurrentAnimData.Clips[pose.PrimaryClipId];

                var clipPlayable = m_animationMixer.GetInput(0);
                if (!clipPlayable.IsNull())
                {
                    m_animationMixer.DisconnectInput(0);
                    clipPlayable.Destroy();
                }

                clipPlayable = AnimationClipPlayable.Create(MxMPlayableGraph, clip);
                MxMPlayableGraph.Connect(clipPlayable, 0, m_animationMixer, 0);
                clipPlayable.SetTime(0.0);
                clipPlayable.SetTime(0.0);
                MxMPlayableGraph.Evaluate(0f);
                SceneView.RepaintAll();

                MxMPlayableGraph.Destroy();
                transform.SetPositionAndRotation(basePosition, baseRotation);
            }
        }