when paused, how can i in script keep the cursor from becoming invisible and staying in the middle, but when i am unpaused, how do i show the cursor, but then when the left mouse button is pressed or held down, it makes the cursor invisible and positions the cursor in the middle? ( the regular cursor ). the problem here is even if i’m in pause mode, and i go to click the screen, the mouse still disappears.
The default cursor in your Project Settings is blank. When your Cursor.visible == true, but you have a blank cursor, it’s going to be invisible whenever the game has focus.
@halley1 what i mean is, when i am unpaused and click the screen, the cursor becomes invisible and moves to the middle of the screen. that’s correct. but when i pause the game and click, the cursor STILL becomes invisible and moves to middle of screen. I only want it to move to the middle and be invisible when NOT paused.
It sounds like you want to create a script that hides the mouse cursor when the game is not paused and shows the mouse cursor when the game is paused. +1 for spiney’s reply. You can also figure things like this out by setting a breakpoint on a thing you want to run, starting your IDE debugger with breakpoints disabled, then turning on breakpoints when you think the code should be running. If your debugger doesn’t stop where you think it should, then you have a logic error somewhere that needs fixing.
As the code stands right now, it looks like you mistakenly reversed your cases. You describe wanting to show and unlock the mouse cursor when the game is paused, but the conditional case for when the game is paused actually locks and hides the cursor. It should be the opposite.
If you want to be able to selectively hide and lock the mouse cursor when unpaused when the mouse isn’t currently paused, you can use Input.GetMouseButtonDown to detect when the mouse is pressed, and combined with a check for whether the game is unpaused or not, you can achieve the behavior you want.
Hope this helps!
Did I successfully make this reply read like a ChatGPT output?
I wouldn’t go with waiting for a mouse press to hide the cursor again, I would check for changes to the pause state and lock when going from paused to unpaused. A typical design involves the state change itself being triggered by pressing a resume button or something like that, and this interaction would normally be expected to hide the cursor right away.