For future reader, you can find a good sample here : Handling pointer events on render texture
It shows how to use PanelSettings.SetScreenToPanelSpaceFunction()
and gives an implementation to get the UI space pointer position from a raycast on a 3D mesh.