Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

How do I distinguish the left mouse button from the right?

Discussion in 'Input System' started by DerrickLau, Jul 24, 2021.

  1. DerrickLau

    DerrickLau

    Joined:
    Sep 29, 2013
    Posts:
    70
    Hello all! Thanks for reading!

    I am using the new Unity input system and am currently designing the input action asset to control a mouse pointer on the screen. I want the left button to be held down for dragging objects across the screen, and the right button to be held down for connecting objects with a line.

    However, when I assign actions and attempt to bind them to the mouse scope, there is no way to differentiate between the left mouse button vs the right mouse button.

    Please see screenshots: 20210724_UnityInputActionsAsset1.jpg 20210724_UnityInputActionsAsset2.jpg
     
  2. DerrickLau

    DerrickLau

    Joined:
    Sep 29, 2013
    Posts:
    70
    I clicked on the little arrow to the left of the action and got to the screen where I could assign the primary action path. I pressed on the T icon beside the field to turn it into a drop down, and clicked on the drop down. I then clicked the Listen button and clicked my mouse button, but nothing happened:

    20210724_UnityInputActionsAsset_ListeningForMouseButton.jpg
     
  3. Rin-Dev

    Rin-Dev

    Joined:
    Jun 24, 2014
    Posts:
    557
    Couple questions then.
    1. Have you restarted Unity yet since installing the new input system
    2. Do you have options without using listen?
    If you have it set to old input system still in the player settings or haven't restarted Unity yet then it won't work.