2d animator wait till animation ended

Hello,

im trying to make a sidescroller game.

My problem is, i want to create an attack state.
I created with the animator an animation called dolch1.

The condition is if the boolean Attack is on true its animates and if not it goes back to idle state.

Ive found no property or method to determine whether the animation have ended.

Ive found somewhere where you can determine if a specific animation is playing

anim.GetNextAnimatorStateInfo(0).IsName('dolch1')

But since it is in an endless loop i cant use it.

How can i know when an animation have ended?

If you are able to unloop the animation via the Import Settings you can go into your mecanim. Make your idle animation default but when the attack bool is true make the link between Any State and your Attack animation.