Button Click - How can i execute function from different object?

script is attached to gameobject.
I am trying to access mybutton’s click event from that script.

  • void start(){
  • var mybutton =GetComponent();
  • Debug.Log(mybutton);
  • mybutton.onClick.AddListener(()=>{ buttonClick(1);});

But it is always null.
Why am i not able to access the button?
Do i need to rewrite all the code in mybutton from mygameobject?

I have included using UnityEngine.UI;

Script is attached to mygameobject and i can access the gameobject through this script. But mybutton is not accessible. How do i access it?

If it is not possible, If i attach a different script for mybutton, how can i transfer the call from mybutton script to mygameobject script?

If the mybutton is clicked, few functions from mygameobject should be called. How can call them?

Is there a button on the exact same transform as this script? If not, it won’t find it.