Assign event trigger methods from code

I have a custom editor for a script. Script requires EventTrigger component.

What I want is - whenever I add my script to game object, automatically assign methods in that script to event trigger’s triggers.

Here’s the excerpt of the code so far:

 public void AssignEventMethods()
  {
    var et = GetComponent<EventTrigger>();

    EventTrigger.Entry e = new EventTrigger.Entry();
    e.eventID = EventTriggerType.PointerDown;
    e.callback = new EventTrigger.TriggerEvent();
    UnityAction<BaseEventData> call = new UnityAction<BaseEventData>(OnMouseDown);
    e.callback.AddListener(call);
    et.triggers.Add(e);
  }

  public virtual void Select() { }
  public virtual void SetStatus(bool isEnabled) { }
  public virtual void OnMouseDown(BaseEventData data) { }
  public virtual void OnMouseEnter(BaseEventData data) { }
  public virtual void OnMouseExit(BaseEventData data) { }

I attached a picture for better understanding. For now I decided to stick with assignment through button.
What I want is - wherever I click “Assign” button, Unity automatically makes EventTrigger entry (it was added manually in the picture).
So far I get just empty list in EventTrigger, with no method assigned.

Hope I explained alright.

3350718--262093--pic.png
3350718--262094--pic2.png

Two ways you can do it

// use this method to right-click the script and click Assign
[ContextMenu("Assign Methods")]
public void AssignEventMethods()

// use OnValidate to assign the method
private void OnValidate()
{
    if (Application.isPlaying)
        return;
    if (!assigned) // check somehow to see if they're already assigned
        AssignEventMethods();  
}

I still get the same result - empty event triggers block, as in screenshot I attached.