Mouse Clicks not detected in new Input System

Hello,

I am currently on Unity version 2021.1.15f1.

I created an Action of Type Button that uses a Binding of Left Button [Mouse], while running the game when I click the left mouse button it does not call the associated function. As a test I added a Gamepad button and it called the function as expected. (don’t think its script related)
7440551--912050--upload_2021-8-23_0-2-25.png

I have an Input System UI Input Model (Script) assigned to a game object.
I have an Event System added as well.
7440551--912056--upload_2021-8-23_0-5-34.png

In the Input Debugger I see that it registers the mouse clicks.

Keyboard and Gamepad input works fine.

I am making sure I click on a UI element that should detect the raycast, but should that even be necessary?

Any ideas what the issue might be? It’s a Logitech G300S mouse.

1 Like

I tried a different mouse today with the same results, Input Debugger detects the clicks, but the Game does not.
¯_(ツ)_/¯

1 Like

After further testing I notice that when I right click in the Game view it changes from Move tool to View tool. This is starting to seem like a bug?

7443467--912500--upload_2021-8-23_20-47-28.png

Your event system makes use of the left click so you either need to check it another way like “Mouse.current.leftButton.wasPressedThisFrame” or maybe you can edit the eventsystem parameters.

2 Likes

Well that worked, I felt like I was missing something obvious. Thanks

Found this after the fact, thought it might be useful for someone looking for similar info:
https://docs.unity3d.com/Packages/com.unity.inputsystem@0.9/manual/Migration.html

I ended up using something similar to below, not wanting to run code in Update() if not required:

private InputAction leftMouseClick;

private void Awake() {
    leftMouseClick = new InputAction(binding: "<Mouse>/leftButton");
    leftMouseClick.performed += ctx => LeftMouseClicked();
    leftMouseClick.Enable();
}

private void LeftMouseClicked() {
    print("LeftMouseClicked");
}
5 Likes

Hi there, what I did in my case is to open the “Input Action” asset and in your control schemes, select the keyboard scheme you created and edit it to add a Mouse control. Like this:
7774722--980421--upload_2022-1-1_21-55-43.png

28 Likes

Just playing around with the new input system and couldn’t get mouse to work, you nailed it. Thanks.

1 Like

I LOVE YOU THANKS, YOU SAVED ME

For me, the issue was that I had a child object with a canvas group and the option “Block Raycasts” enabled. Once I disabled it, mouse click was back!

8959071--1230705--upload_2023-4-19_10-43-23.png

3 Likes

FOUND IT!
If for you too well the InputManager is not accepting the inputs from the mouse and or not detecting its being used used (ie Control Schemes to know when a KBN or gamepad is used).
Then ensure that in your “Kb and mouse” scheme the Mouse is first in the list.
Unity Version : 2021.3.5f1
9002392--1240375--fffunity.png

1 Like

If you encounter similar problems, you can try the following methods


source: Need help! Unity Input System Mouse totally not detected, clicks not happening

3 Likes

An other option I found which was my solution is to:

Window > Analysis > Input Debugger > Options > Add Devices Not Listed in "Supported Devices"

For some reason my basic mouse was not considered supported.
2021.3.14f1

3 Likes

Life saver thank you

For me i was in simulator mode. As soon as i changed it to game mode it is working.

Thank you. My mouse was supported, just disabled by default…

Thank you, so much. I was about to pull out significant chunks of hair because I could not figure out why mouse events where not picked up. This solved it.

I want you to know that i made an account just so i can say thank you so damn much

Two years later and you saved me. Thank you!

In case anyone is having the same issue as me:
I was trying to use the built in “Click” action in the UI action map (from the provided “InputSystem_Actions” asset), and subscribe to the “started” callback. However, because the “Click” action in the UI action map is set up as a “Pass Through” rather than “Button” action type, the “started” callback is not used (see here for more: https://docs.unity3d.com/Packages/com.unity.inputsystem@1.14/manual/Interactions.html#default-interaction)

I could instead subscribe to the “performed” callback, but this will be called both on mouse click and release, which was not the behavior I wanted. So I instead created a new action, bound to the left mouse button, and with the “button” action type.

1 Like