Cursor lock state locked not locking the cursor in center

When I use cursor.lockstate = cursorlockmode.locked doesn’t lock it to the center it makes the cursor invisible but the cursor moves in the editor it hovers over the application like you can press close ,minimise etc when I press escape key it shows the cursor and it is not working it is working in unity 2018.4 but not in unity 2020.3.10 please help me

Yes, It is because Cursor.LockState(“Locked”) only locks the cursor inside the game and since in the editor …your game is only limited to the gameview scene so if you tried to slide your cursor more than the gameview screen , then the cursor will eventually come out