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

Get Mouse Click Position

Discussion in 'Input System' started by sedlu, Dec 9, 2019.

  1. sedlu

    sedlu

    Joined:
    Nov 12, 2012
    Posts:
    11
    Just began to try the new input system.

    I want to configure the ActionMap as having tap (when on touchscreen) and mouse click (when on pc) have the same effect to return the position where the user taps/clicks. And I expect that in the callback body I can focus on only the position it returned, just like:

    Code (CSharp):
    1.  public void OnMove(InputValue value)
    2.     {
    3.         Debug.Log(value.Get<Vector2>());
    4.     }
    However, so far I still find no way to properly configure the ActionMap to achieve this. The closest way is to check whether the left mouse button is clicked in the callback body. But this way seems not so ideal as it breaks the abstraction and encapsulation, which are the design objectives of the new input system.

    Could someone please give me some suggestions?

    Thanks.
     
    Kazko likes this.
  2. Kazko

    Kazko

    Joined:
    Apr 2, 2014
    Posts:
    82
    I tried for hours and was not able to do this. Gave up with great frustration. It's either a click, or position.

    Ended up using "Press [Pointer]" binding just to trigger the event, and in the callback I looked at Pointer.current.position ...

    It's so sad that such a basic thing is so counter-intuitive to achieve in the new system.

    I hope someone steps in to explain how to do this.
     
  3. Jichaels

    Jichaels

    Joined:
    Dec 27, 2018
    Posts:
    237
    I'd use polling for this aswell. Get a reference to a Mouse (or pointer) position, and in your "click" callback get the value of the position action.
     
  4. WilliT

    WilliT

    Joined:
    May 3, 2015
    Posts:
    1
    I have the same concern and was working my way through the demo/sample project to try and figure it out.

    I've attached a screenshot from the demo/samples provided with the new input system, which shows what looks like a fifth composite binding: "Pointer Input".

    I've tried just about every combination of control scheme/action type and property and still can't find this binding. Could someone please help a newbie out?
     

    Attached Files:

  5. Kazko

    Kazko

    Joined:
    Apr 2, 2014
    Posts:
    82
    I think that is their custom written composite, which is some kind of a custom combination of data. I gave up right there, hoping that for sure they would not require us to write custom composites for such a basic thing. But it very well may be that this is the case:/