Checking if Animator has finished the animation. C#

Hello my fellow developers,

I am struggling with my c# script.
I want to check if the animator has ended the animation.
And when it had indeed ended I want an event to follow up.

(So I want to make an if(statement){} )

What do I have to put into the if(…){} to check if the animation had ended
I thought something like if(!anim.IsPlaying) but this is not working.
Maybe because the object itself doesnt have an animation component attached to it. The object only have a spriterenderer and animator at the moment.

The script is gonna be attached to the object with the animator.
I have been searching all around in the doc.reference of Unity. Couldn’t find the answer.

Hopefully you guys can help me out.

-Hexer

Currently, the only way to get current animation being played by the animator is by adding keyframe event.

As mechanim determines how the animations will be run internally, there is no direct access to animations.