I’m making a pause menu, and I want to make it so that when the menu is on, the mouse will be visible and you can move it around, and when the menu is off, the mouse in invisible and is centered. I was able to get the invisibility toggle to work, but for some reason, the locking in won’t work. Here’s what I have.
You use namespace UnityEngine manually to get Cursor for changing the visibility. I suggest that you did not include UnityEngine at the beginning of the entire script. Therefore, the lines when you include the namespace manually work, but others where you do not include it, doesnt. So, write this line at the beginning of the script:
import UnityEngine; // If you use JS
using UnityEngine; // If you use C#
And now you can also remove “UnityEngine” before Cursor.visible.
The UnityEngine namespace was already imported or else Cursor.lockState = CursorLockMode.None wouldn’t compile, so that makes no difference. In any case, it works fine here. What about it suggests that the mouse locking isn’t working?