Use first person camera to trigger IPointer events,Lock mouse without disabling mouse event triggers

I’m trying to make a first person game that allows the player to:

  1. Click on objects in 3d to interact with them
  2. “Pause” the game and interact with a 2d menu (the game doesn’t need to freeze; in fact, ideally, it would work like System Shock’s UI, where you can use your mouse to interact with the 3d world in real time while in the inventory screen)
  3. Interact with various world-space UI screens

As far as I can tell, I should be able achieve all this with a physics raycaster and IPointer events. I would toggle in and out of the pause menu with a key, and the mouse event systems should work in either mode. However, it seems that whenever you lock the cursor with CursorLockMode.Locked as the FPSController does, it locks the cursor to position (-1.0, -1.0), thus rendering the mouse useless, so neither 1 nor 3 would be possible.

I considered switching to a Physics.Raycast system whenever in first person mode, but I don’t know how to get that to work with world space UIs (nor do I want to add 3d colliders to all the 3d UI’s elements).

Ideally, I’d like to know if there is a way of locking and hiding the mouse in fps mode without disabling its pointer event interactions or if I could very easily hook a Physics.Raycast from a camera into the IPointer event system.

Have a look at the first answer from this thread, it fixed this exact same problem for me.