Cannot hide mouse cursor anymore

Hi all,

The following code used to work in Unity 3.0 without an issue:

`

public class Crosshair : MonoBehaviour
{

void Start()
{   
    Screen.showCursor = false;
}
void Update()
{
    Screen.showCursor = EngineHelper.Paused;
    Screen.lockCursor = !EngineHelper.Paused;
}

}
`

But since updating to Unity 3.3 it no longer does.
The mouse still locks and unlocks but the cursor flickers on and off.

I have checked in both editor and Windows 7 standalone / web player build with exactly the same result.
There is nothing else in my project that is setting the mouse cursor other than this script.

Does anyone know if this is a bug?
If so is there a work around?

Thanks in advance.

[edit] [moved up from below] If I build&run the same project, it works perfectly -- no flicker. Problem seems to be only in Play from the Editor.

I've got the same problem with a nearly empty Unity project, nothing else running, on Windows7. Setting `Screen.showCursor=false;` in Start. Getting a very intermittent flash of the real cursor (a single or double flash every second or two.) Doesn't seem to matter what the mouse is doing.

I'm using a fake guiTexture for the cursor, and changing the texture on that, randomly as a test. Doing or not doing that doesn't seem to affect the flickering at all. Tried moving it across some other guiTextures -- flicker rate unchanged.

One thing that seems to increase flicker rate is Active/Inactive. I'm hiding certain other guiTextures when the cursor is over them, and this seems to reliably cause the "real" cursor to flash on. I move over the guiTexture, my code turns it inactive, and I get extra flickers of the real cursor for the next 1/2-second.

  • Are you sure EngineHelper.paused it not the cause, and that the variable is always false when you expect it to be?
  • Have you tried simply using Screen.showCursor = false; to rule out a bug?
  • It could be because you are continuously setting Screen.showCursor, try only setting it if EngineHelper.paused changed. if(!Screen.lockCursor && !EngineHelper.paused) { Screen.lockCursor = true; }else if(!Screen.showCursor && EngineHelper.paused) { Screen.showCursor = true; }

I had this same problem. My solution was that I had PlayMaker running with “control mouse cursor” checked. I unchecked it and it solved the problem. You may have a similar issue.