RaycastHit2D hit = Physics2D.Raycast(Input.mousePosition, Vector2.zero);
if (hit.collider != null)
{
Debug.Log("Clicked on Object!");
}
// Requires for the object to have a collider and this script attached
private void OnMouseDown()
{
Debug.Log("Clicked on object!");
}