How do i pass the button event to a script attached to the canvas or empty gameobject?

I have four buttons. All the buttons have the buttons script for onclick.
The process is difficult for me.

I am thinking that passing the button click to the canvas or empty gameobject will make the work easier. Because i want to write some animate script on the gameobject which will be dynamically created.

Right now, it is created in the button script.

GameObject go = new GameObject(directions[activeItem]);
		SpriteRenderer renderer = go.AddComponent<SpriteRenderer>();
		renderer.sprite = mysprite;
		Vector3 center = new Vector3(404,273,0);
		go.transform.position += center;		
		go.transform.localScale = new Vector3 (2, 2, 2);

Game object is created inside the button. So, I don’t know how to animate. I just can’t use inside the update which will give animation to the buttons.

Please advice what is the best solution for this?
Passing the button click to canvas?
Or animating the gameobject in button itself?

I tried to add the following line to catch the button click it didn’t work.

public Button button_name;

button_name.onClick.AddListener(() => {
   debug. log('test');

But it is giving me error.

I don’t know how to animate the sprite inside the button script. So i am struck here!

Is it something like this you are looking for?