How to stop hidden cursor from highlighting ui items?

Whenever I hide the cursor, it remains in position and new UI elements respond to it. For example, if the cursor is made hidden, if I open a new menu on the screen, and a button happens to fall below the cursors previous position, it immediately becomes highlighted.

I first noticed this issue on Steam Deck because it auto-hides the cursor when you start using the controller. I decided this was a good thing to do in Unity in general for PC play as well. The issue is, I cannot seem to figure out a way to make it stop highlighting things after it is hidden.

isVisible = false obviously doesn’t work for that. Locking it locks it to the center of the screen which is frequently where UI elements for pop up menus exist.

I thought maybe I could move the cursor to the side of the screen and then hide it, but there doesn’t seem to be a cross-platform way to do that that I can find.

I am using the Input Action system and I tried setting “Point” to “None” on the EventSystem’s InputSystemUIInputModule, but that had no effect. I feel like maybe I am on the right track with this approach, but I must be misunderstanding something.

Any ideas? Thanks.

Not sure if this is the best answer, but this is how I do it. I would just disable the UI input module alongside the cursor, and/or make the canvas non-interactable with a CanvasGroup on the top level

Disabling the InputManager unfortunately seems to disable controller input as well. And making things not interactable I would think would have the same effect.

Edit: I have also now tried separating the Mouse input into a separate ActionMap and disabling that ActionMap, and that does not solve the issue either. Invisible mouse continues to interact with new menus.

Welp. I don’t know why it didn’t work the first time, it was the first solution I tried, but setting Cursor.lockState = CursorLockMode.Locked is exactly what I needed. There’s a setting in the Input Module component on the EventSystem that let’s you specify where to lock it to (center or outside screen), but regardless it seems to turn off it’s interaction with the UI to begin with so it doesn’t matter which I choose in my case.

1 Like