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

(New Input System) Check if .performed == null

Discussion in 'Input System' started by nvidialover, Oct 5, 2021.

  1. nvidialover

    nvidialover

    Joined:
    Aug 12, 2020
    Posts:
    6
    Is there any way to see if .performed has any methods in its invocation list? I want to do a simple check to see if there's anything in it and add only if it's empty.

    Code (CSharp):
    1. if( _playerinputActions.Player.LMB.performed == null)
    2. {
    3. _playerinputActions.Player.LMB.performed += DoSomething;
    4. }
    5.  
    6.  
    This doesn't work. I'm only starting to get into the new Input System, so there's probably something I'm missing here.
     
  2. dmytro_at_unity

    dmytro_at_unity

    Unity Technologies

    Joined:
    Feb 12, 2021
    Posts:
    212
    Right now, not really, one way to do it would be to have a boolean on your side and only add callback if bool is false and then set bool to true.
     
  3. nvidialover

    nvidialover

    Joined:
    Aug 12, 2020
    Posts:
    6
    I see. I looked at the input system, and the delegate attached to the event is private, so I can't access it. Thanks anyway, I did it the way you described.