How do I know from which layer an animation event was fired?

My problem is that I am using the same animation on multiple layers at the same time and each layer triggers an animation event. I want to know which layer the event was triggered in order to execute logic only for a specific layer.
After a few hours of searching, I found out that the event method can take an AnimationEvent as an input parameter, I thought that the problem was solved and I tried to do this:

public void Attack (AnimationEvent evt)
{
            if (evt.animationState.layer == Layer)
            {
                ///
            }
}

But now I am getting this error - AnimationEvent was not fired by Animation component, you shouldn’t use AnimationEvent.animationState
UnityEngine.AnimationEvent: get_animationState ()
Debug shows that evt.animationState == null

How can I solve my problem?

I don’t think it’s possible to get the layer an event comes from when using Animator Controllers. I made my own custom event system for my animation system, but for a simple workaround the best you can do is probably duplicate the animation for each layer and give them different events (or give the event an int parameter to indicate the layer).

Also note that taking an AnimationEvent parameter allocates some garbage every time the event is triggered.

Thanks for the answer, I’ll try the duplication trick.
But this does not solve the global problem, the unity should definitely change its animation system. Every time you need to do something more difficult than a simple movement with blendTree, it turns into hell