How to make a button like this,How to make button that will interact

void OnTriggerStay2D(Collider2D other)
{
if(other.gameObject.name == “Player”)
{
if(Input.GetKeyDown(KeyCode.Space))
{
dialougeM.ShowBox(dialogue);
}
}
}

instead of getting the input key and pressing “space” to open the dialogue I want to make a UI button that will open that dialogue box

for example, I have “A” button in my UI and when i tap that button it will open the dialogue box instead of pressing the “space” key

In your case you would use dialougeM.ShowBox(dialogue); in your OnClick. You may put this OnClick in whatever script suits you. Just make sure you have a reference to your dialog manager (dialougeM, I presume).