How to make the transparent parts of a sprite also clickable using a Raycast

I have been making using the following code to add mouse clicks to my game objects.

RaycastHit2D hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero);
    if ((hit.collider != null && hit.collider.gameObject.name == gameObject.name)
    )
    {

    //do something here
}

I have a game object which I made using a sprite with transparent areas. I would like the transparent areas to also be recognized as the game object being clicked. I am not sure if this can be achieved using a raycast. If not, I am open to other ways of achieving the same result.

1 Like

raycast needs collider there, if you cannot add larger collider,
then maybe can check if mouse is inside sprite bounds