2D Selection through raycasting

I’m making a top down RTS style game and I’m trying to get troop selection to work through shooting a raycast from the camera to where the mouse is. I’m doing this in 2D and what I want it to o is shoot a raycast and return the name of the gameobject but it doesn’t. Please help.

void update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            Select();
        }
    }

    void Select ()
    {
        RaycastHit2D Selectinfo = Physics2D.Raycast(Camera.main, Input.mousePosition);

        if (Selectinfo)
        {
            Debug.Log(Selectinfo.transform.name);
        }
    }

I actually never did it in 2D, but if it’s similar to how you do it in 3D, you’ll need to call something like camera.ScreenPointToRay(Input.mousePosition) to get your ray, like described here: Unity - Manual: Rays from the Camera