how do i lock the mouse at center and lock it

ok i have a very simple question and i cant find any answers anywhere its trivial and it requires some fine tuning when i find the solution but is there any way to update the mouse position and keep it in the center of the screen when the result of a bool remains false and then unlock the cursor while it remains true, the reason i’m asking this is because im developing a game that requires this to happen , when the boolean is true the game is paused and the user may select to quit game restart etc but then when the game plays it needs to be in the center in all frames or done with time.deltaTime so that the user can use the cursor to interact with the world, any prompt answers or links will be appreciated thankyou

Set the mouse.position in each Update() to the screen center. Don’t use fixedupdate() because that can cause problems with the mouseinput.