tap detection on a gameobject

Hello! i’m trying to make a simple Android game in which i have to tap on an object.
the problem is that when i attach my script to the main camera I get results no matter where i touch, but i want only if i touch on my gameobject collider.
btw im using 2D mode. this is the script :

void Update()
{
if ((Input.touchCount > 0) && (Input.GetTouch(0).phase == TouchPhase.Began))
{
Ray raycast = Camera.main.ScreenPointToRay(Input.GetTouch(0).position);
RaycastHit raycastHit;
if (Physics.Raycast(raycast, out raycastHit))
{
if (raycastHit.collider.CompareTag(“Egg”)) // (no, i didnt forget to add a tag)
{
//what i want to do.
}
}
}
}
}

after using raycast I dont get any results at all :/.

I don’t know why that’s not working, but an easier option would be to just have a world-space button as a child of the GameObject.

Edit: You’d make the button invisible of course, and you could also give the button a collider, if you want a collider that isn’t a rectangle.