Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Multiple interactions: can Press and Multi Tap co-exists on an action?

Discussion in 'Input System' started by bitinn, Oct 12, 2021.

  1. bitinn

    bitinn

    Joined:
    Aug 20, 2016
    Posts:
    961
    Hi,

    I am using Player Input component's Invoke Unity Events to receive input, and I would like to handle click and double click from my mouse.

    Based on the manual, it appears we can set multiple interactions on a binding.

    But how about an action??

    Say I already had an action associate with mouse's left button, set its action type to Button, added a Press Only interaction.

    - Can I add a Multi-tap interaction?

    - If so, how can my Monobehaviour script distinguish between the Press Only and Multi Tap event? Note that I am using Invoke Unity Event, so all I have is InputAction.CallbackContext.

    Thx!
     
  2. bitinn

    bitinn

    Joined:
    Aug 20, 2016
    Posts:
    961
    Answer:

    CallbackContext has a
    interaction
    property that I can use to distinguish between interactions.

    Which I can do a check like
    if (context.interaction is MultiTapInteraction) {}


    Comment:

    I would love Unity team to document it somewhere.