Mouse Input disabled on scene load

Hi all,

I’m not sure what I did (wrong), but for some reason I lost my entire mouse input. Keyboard input is still working fine. I’m using Playmaker and Unity 2020.3.24f1

This was working fine before. It stopped working from one day to the other and I cannot for the life of me think of what I might have changed between those two states.

The original setup:
I defined an action in the input system for the left mouse button and the space bar. Both are in a “Mouse & Keyboard” Control Scheme with the devices “Keyboard” and “Mouse” set to “Required”.
Both inputs worked fine.

When I run the Input Debugger it shows the mouse as DISABLED as soon as I load the scene.

When I go into playmode and force-enable the mouse it still does NOT work and I get no readings in the debugger. When the level is reloaded, I can see that the mouse is disabled on load, so I am assuming that there is something in the initial setup that disables the mouse input.

Things I’ve tried:

  • A new scene in the same project doesn’t have the issue. Mouse input is working fine on both normal player input as well as UI elements.

  • I then tried creating a new scene and copying over all Game Objects from the problematic scene. No joy.

  • I removed the player input component and created a new one.

  • I removed all other entries from the input system.

  • I removed the Event System and recreated it.

  • I have added another key binding with the same action on the keyboard and that works fine too. So I am sort of ruling out the Input System as the culprit. All other inputs seem to be working.

  • I set up a global transition for MOUSE DOWN as well as UI CLICK on an empty GO, which are never triggered.

  • The only situation where an input seems to be detected is when I query “ANY KEY” to trigger a reload of the scene, but I cannot seem to get a button pressed (and held) signal.

Any pointers would be greatly appreciated.

2 Answers

2

After hours and hours of debugging, I fixed this by deleting the existing Event System and adding an empty GameObject and adding Input components to that. This automatically created a new Event System as a component. This seems to have fixed the issue. No idea, why it was broken in the first place.

You can also do a script that will call it once on the void Start()
An example that will work.

Place the script anywhere or on the canvas or create an empty Object and place this script on it.

void Start ()
{
Cursor.lockState = CursorLockMode.None;
Cursor.visible = true;
}

That will work once you leave the scene and go back to it using the script above it will kick in, and Cursor will work and begin to interact with the loaded scene.

It shouldn’t be that way, but it works. Cheers!

WP