unity animator check if animation is playing

Code Example - unity animator check if animation is playing

                
                        bool isPlaying(Animator anim, string stateName)
{
    if (anim.GetCurrentAnimatorStateInfo(animLayer).IsName(stateName) &&
            anim.GetCurrentAnimatorStateInfo(animLayer).normalizedTime < 1.0f)
        return true;
    else
        return false;
}
                    
                
 

check if animation is playing unity

                        
                                if (myAnimator.GetCurrentAnimatorStateInfo(0).IsTag("Example"))