Can't hide the cursor

For some reason, when I switch Active Input Handler from Input Manager to Input System I can no longer hide the cursor.

Even setting this every frame does not hide it.

Cursor.lockState = CursorLockMode.Locked;
Cursor.visible = false;

The cursor just sits in the middle of screen vibrating a little before snapping back when I move the cursor.

Tested both in editor and at run time on windows. 2018.3f2

Weird, I have just tested and I do not experience the problem. It may have some other cause. (I set both the lockState and the visible in Awake)
Also tried with “Input System” and with “Both” setting.

I checked the entire project, no other use of lockstate or visible anywhere so I don’t know what is up.

It was working fine before I switched over so not sure what else could be the cause.

Input version? I have the latest I can see: 0.1.2-preview.

0.1.2-preview

I don’t really know why this would cause the issue, the input manager doesn’t seem responsible for the unity cursor behavior.

Ok, definitely something to look at. The Cursor API should be unaffected by that switch but could well be there’s something we missed. Filed a ticket here.

Hi!

Sorry for reviving this thread, but I’m still facing this problem. I’m using Unity 2019.4.6f1 and the New Input System version 1.0.0.

When setting the player settings to use only the New Input System, the cursor remains visible, no matter if I put the Cursor.visible = false and Cursor.lockState = CursorLockMode.Locked. However, if I change the player settings to use both inputs, the cursor’s visibility works as it has to.

Is there any way to fix this using only the new input system?

Thank you very much!

1 Like

@Schreilem I’m running into a similar issue, I tried generating a custom transparent texture to “hide” the cursor but that ended up just creating a all black texture on the mouse. I looked into the bug report and its says fixed in 2020.1… which is not useful as I can’t update my project past 2019 for now. How did you end up setting unity to use both inputs? That seems to be the only solution for now…

1 Like

Still having this issue in 2020.1.4f with the new input system 1.0.0

My dirty and wasteful work around is to run Cursor.visible = false; every frame.

EDIT: This method is very flaky and suddenly stopped working.

Hi, I have a workaround for this. It’s not ideal, but it kinda works. Just customize the cursor image to a null texture. Like this line:

Cursor.SetCursor(null,Vector2.zero,CursorMode.Auto);

Obviously you don’t have to call it every frame so it’s not terrible, but as I said, not ideal, and you should remember to set a sprite when you actually need the cursor again. Hope it helps!

1 Like

Confirming this is still broken. InputSystem v1.1 on Unity 2019.4. No matter what I do, the hardware cursor stays visible, unless I toggle Both for input system usage.

Can confirm. The issue is tracked here btw: Unity Issue Tracker - The Cursor is visible when Cursor.visible is set to false and new InputSystem package is used

In editor, I can get the cursor visibility to work properly in most cases if I move it into the game view window immediately after hitting the play button.
In builds, however, cursor visibility seems to be broken in most cases (i.e. always visible) - especially when the game runs in windowed mode.

This issue is quite frustrating (I wouldn’t care that much about the editor, but it’s annoying that this also happens in builds). Are there any news about this issue @Rene-Damm ?
I’m using Unity 2020.1.11f1, Input System 1.1.0-preview.2 (but this bug was also present in the verified 1.0.0 package), HDRP 8.2 and the latest UI Toolkit package, just in case this matters…

It works if I do it like this. (in editor, haven’t tried build)

private IEnumerator HideCursor() {
yield return new WaitForSeconds(3);
Cursor.visible = false;
Cursor.SetCursor(null, Vector2.zero, CursorMode.Auto);
}

Removing the visible = false breaks it again.
Then I call Cursor.visible = true; when the mouse moves and the mouse is back for some reason.

The odd thing is that setting the cursor to null just means you’re using the default cursor texture.
But what ever it works I guess.

I am also getting this bug. Seems strange this hasn’t been fixed yet.

It’s added to the known issues in the latest unity 2019 release notes though.

None of theses workaround are working in the editor for me, @lejean_1 code made the cursor invisible while over the game windows but didn’t locked it in.
Adding Cursor.lockState = CursorLockMode.Locked; did the trick though !

void Awake()
    {
        StartCoroutine(DelayedLockMouse());
    }
   
    IEnumerator DelayedLockMouse()
    {
        yield return new WaitForSeconds(1f);
        Cursor.visible = false;
        Cursor.SetCursor(null,Vector2.zero,CursorMode.Auto);
        Cursor.lockState = CursorLockMode.Locked;
    }
1 Like

This doesn’t seem to work for me either. It locks the cursor, visibly to the center after 1 second. What does work for me however, is clicking the game view before Cursor.visible is called. This code does help with that (by giving me a 1 second window).

I’m experiencing a similar problem but this time it is with setting the Cursor.lockState to CursorLockMode.Locked. In an empty 2019.4 project I have tested a simple script attached to the main camera that sets the lock state in Update(), but the cursor is free to move. I’ve tested this in the editor as well as the built version of the project. I have replicated the bug on two machines. Am I missing something about how this feature is suppose to work or be set up?

I have the exact same problem with 2020.3.01f. I filed a bug report and started a Reddit thread here: https://www.reddit.com/r/Unity3D/comments/m4j02d/latest_lts_release_202030f1_and_cursor_locking/