Search Unity

Question InputAction does not contain "wasPressThisFrame" error

Discussion in 'Input System' started by cnqdztp, Nov 11, 2021.

  1. cnqdztp

    cnqdztp

    Joined:
    Apr 28, 2021
    Posts:
    3
    I am "using UnityEngine.InputSystem;"

    error CS1061: 'InputAction' does not contain a definition for 'WasPressedThisFrame' and no accessible extension method 'WasPressedThisFrame' accepting a first argument of type 'InputAction' could be found (are you missing a using directive or an assembly reference?)

    Code (CSharp):
    1. private InputAction[] actions;
    2.  
    3. public override bool GetTrackActionKeyDown(Track track, int index)
    4.         {
    5.             var key = actions[index];
    6.             return key.WasPressedThisFrame();
    7.         }
     
  2. Actions don't have
    WasPressedThisFrame
    . They can be other things than keys and buttons. They have triggered.
     
  3. andrew_oc

    andrew_oc

    Unity Technologies

    Joined:
    Apr 16, 2021
    Posts:
    77
    @cnqdztp This method was added in version 1.1.0-preview.2. I suspect you have an older version of the Input System package installed.
     
  4. Oh you actually added extension methods? May I ask you why did the team choose this over what we have in ButtonControl (property as opposed to methods)? This is super-confusing, even for me.
     
  5. andrew_oc

    andrew_oc

    Unity Technologies

    Joined:
    Apr 16, 2021
    Posts:
    77
  6. Yes, we are, sorry, for some reason I categorized this as extension method. But the meaning of the question still stands, what is the reasoning to have a method instead of a property meanwhile we already have similar pattern and meaning as property elsewhere.
     
  7. andrew_oc

    andrew_oc

    Unity Technologies

    Joined:
    Apr 16, 2021
    Posts:
    77
    Not sure. Evolving standards/guidelines maybe? Probably something we can revisit because it's not the most consistent thing but changing either now would be a breaking change so it can only happen during a major version bump.