Ok, I recently had to implement this very same functionality. I had code for 3D colliders and didn’t want to change it too much.
So in 3D I was doing this:
var ray = Camera.main.ViewportPointToRay(new Vector3(touch.Position.x, touch.Position.y, 0));
RaycastHit hit;
if (Physics.Raycast(ray, out hit)){
//Do stuff
}
The equivalent in 2D is:
var ray = Camera.main.ViewportPointToRay(new Vector3(touch.Position.x, touch.Position.y, 0));
var hit = Physics2D.GetRayIntersection(ray);
if (hit.collider != null) {
//Do stuff
}