How can use OnPointerClick in a generic way?

If I have many buttons in a canvas, I can simply use this:

button1.onClick.AddListener(() =>{doStuff();});
button2.onClick.AddListener(() =>{doStuff2();});

However, if I have images in the worldspace and I want to make them clickable I need to use the EventSystem, attach a physics2D raycaster to the main camera, and a Box Collider 2D to the image, and then have code like this:

using UnityEngine;
using UnityEngine.EventSystems;

public class ClickAction : MonoBehaviour, IPointerClickHandler
    public void OnPointerClick(PointerEventData eventData)


How can I do something like this


That is, use the ClickAction class in a generic and reusable way? Thanks.

the Syntax would look something like this:

ClickAction needs a public method, receiving either a System.Action or UnityEvent you save locally and call when the real OnClick is called.