How do I align my UI panel with a mouse click?

I’m creating a context menu for my game, when you right click on the object it brings up the menu. I want to make it line up with the centre of the clicked object when I hit the mouse.

Right now I have the following code.

void Update()
{
    RaycastHit hit = new RaycastHit();
    Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
    Physics.Raycast(ray, out hit);

    if (Physics.Raycast(ray, out hit))
    {
        Output(hit);
    }
}

   void Output (RaycastHit currHit)
    {
        if (Input.GetMouseButtonUp(1))
        {
            RightClickMenu.SetActive(true);
            RightClickMenu.transform.position = currHit.point;
        }
    }

This seems to put the RightClickMenu panel off screen (seems like it’s using the world coordinates). How do I get the vector3 transform.position of the actual mouse click point on the screen?

I think I might have solved it using the Camera.ScreenWorldToPoint function but that required me to define a camera just to run that, no static option available. Is that the best choice?