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

Official Input System 1.3.0 released: more fixes

Discussion in 'Input System' started by Schubkraft, Jan 10, 2022.

  1. Schubkraft

    Schubkraft

    Unity Technologies

    Joined:
    Dec 3, 2012
    Posts:
    1,070
    Hello again,

    the 1.3.0 package of the Input System is now publically available. It contains mainly more bug fixes. Please see the Changelog for details.

    It will be made available over time via the package manager as usual, but if you want it right now please add it manually by either editing the manifest or via the Add Packge by Name+Version in the newer tech releases.

    Please do keep the feedback coming. It is very much appreciated even when we can't get to all of it right away.
     
  2. Dennis_0172

    Dennis_0172

    Joined:
    Nov 19, 2021
    Posts:
    4
  3. Jonathan-Westfall-8Bits

    Jonathan-Westfall-8Bits

    Joined:
    Sep 17, 2013
    Posts:
    252
    I have a question using InputAction Callback Context that comes from the IActions interface generated by
    an input asset.

    The Callback Context doesn't update when holding the button. It calls during started, performed, cancelled.
    Any way to get this to work with holding a button to keep it firing the functions called inside of the context.
     
    Deleted User likes this.
  4. blackmodjo

    blackmodjo

    Joined:
    May 6, 2014
    Posts:
    14
    Any idea why this new release is not visible in the package manager for 2021 unity ?
     
    goldbug likes this.
  5. Because it is not validated yet. You can install it manually through the
    Add package by name
    option.
     
    moatdd and blackmodjo like this.
  6. PaulMDev

    PaulMDev

    Joined:
    Feb 19, 2019
    Posts:
    71
    Is there anything planed for continuous input support for the PlayerInput component.
    I really like using C# classes (it's way better that having to write the name of the input with a string) but using a component without any programming seems really cool and would be great for beginners.
    But right now it's not that useful since it's only working for things like a jump or an interaction not for movement.

    Will there be an update to add that ?
    (very sorry for my English)
     
  7. Deleted User

    Deleted User

    Guest

    How to check if any key on any connected device was pressed? I can't find an API for that. It was planned for beyond 1.0 as you can see in this post. Is there an easy/convenient way to do it?
     
  8. forestrf likes this.
  9. Jonathan-Westfall-8Bits

    Jonathan-Westfall-8Bits

    Joined:
    Sep 17, 2013
    Posts:
    252
    Hey you are looking for the anyKey method.

    Go to the documentation below and look for anyKey. See if that is what you are looking for.
    It returns 1 if pressed and 0 if no keys are pressed.
    I think you can also do the anyKey.wasPressedThisFrame and anyKey.wasPressed.

    https://docs.unity3d.com/Packages/c....html#UnityEngine_InputSystem_Keyboard_anyKey
     
  10. Deleted User

    Deleted User

    Guest

    Can anyone give an example on how to use this? The docs are not so clear for me .. a code example is the best go! Thanks.
     
  11. "this" what exactly? You got two solutions with vastly different purpose and behavior. Which one are you talking about?
    My link which is a method to actually monitor all devices and all buttons has a code example on the link I provided. The other one which only monitors the keyboard is super simle:
    if (Keyboard.current.anyKey.wasPressedThisFrame) doSomething;
     
  12. blackmodjo

    blackmodjo

    Joined:
    May 6, 2014
    Posts:
    14
    I tried but it doesn't work when you search for Input System or InputSystem or input system i tried also the git url https://github.com/Unity-Technologies/InputSystem.git and i get back the error that the error that it is missing the manifest, i even tried https://github.com/Unity-Technologies/InputSystem/tree/develop/Packages/com.unity.inputsystem

    [Package Manager Window] Cannot perform upm operation: Unable to add package [https://github.com/Unity-Technologies/InputSystem/tree/develop/Packages/com.unity.inputsystem]:
    Package name 'https://github.com/Unity-Technologies/InputSystem/tree/develop/Packages/com.unity.inputsystem' is invalid. [InvalidParameter].
    UnityEditor.EditorApplication:Internal_CallUpdateFunctions ()
     
  13. Here is step by step, obviously you need to use the proper version number:
    https://forum.unity.com/threads/cannot-upgrade-to-beta-versions.1143701/#post-7343153
     
  14. Deleted User

    Deleted User

    Guest

    This is how I'm trying to do it, but it doesn't work:

    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.InputSystem;
    3. public class NewBehaviourScript : MonoBehaviour
    4. {
    5.     private void Update()
    6.     {
    7.         var myAction = new InputAction(binding: "/*/<button>");
    8.         myAction.onPerformed += (action, control) => Debug.Log($"Button pressed!");
    9.         myAction.Enable();
    10.     }
    11. }
    When I press any key, it doesn't print anything in the Console.


    Tried second method as well, but I can't seem to figure it out as there is a persistent error .. here's the code:

    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.InputSystem.Controls;
    3. public class NewBehaviourScript : MonoBehaviour
    4. {
    5.     private AnyKeyControl anyKey;
    6.     private void Awake()
    7.     {
    8.         anyKey = new AnyKeyControl();
    9.     }
    10.     private void Update()
    11.     {
    12.         if (anyKey.wasPressedThisFrame)
    13.         {
    14.             print("Pressed!");
    15.         }
    16.     }
    17. }

    Screenshot 2022-02-01 020142.png

    Error​



    I don't know what am I doing wrong and what this error means .. I'm still fairly new to Unity and just learning the Input System and coding in general. If you could provide a practical example, it would be so helpful and insightful. Thanks again. :)
     
  15. Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.InputSystem;
    3.  
    4. public class NewBehaviourScript : MonoBehaviour
    5. {
    6.     private readonly InputAction _anyKeyWait = new(binding: "/*/<button>");
    7.  
    8.     private void Awake() => _anyKeyWait.performed += DoSomething;
    9.     private void OnEnable() => _anyKeyWait.Enable();
    10.     private void OnDisable() => _anyKeyWait.Disable();
    11.     private void OnDestroy() => _anyKeyWait.performed -= DoSomething;
    12.  
    13.     private void DoSomething(InputAction.CallbackContext ctx) => Debug.Log("'Any' button pressed.");
    14. }
     
  16. Deleted User

    Deleted User

    Guest

    I tried the code you posted, and it works like a charm. However, there's just a tiny problem with it: If you press 'any' key, it will register it, However, once you release it, it will register it Yet Again as well! So, the action is triggered Twice! I'm sorry if I'm annoying you, but how to just do it on 'press' without 'release'? Thanks for the code and your help btw :)
     
  17. Replace
    private readonly InputAction _anyKeyWait = new(binding: "/*/<button>");

    with
    private readonly InputAction _anyKeyWait = new(binding: "/*/<button>", type:InputActionType.Button);


    https://docs.unity3d.com/Packages/c...ual/Interactions.html#predefined-interactions
     
    saskenergy and (deleted member) like this.
  18. Deleted User

    Deleted User

    Guest

    Yes, now it works as expected. Thank you so much for your generous help :D
     
  19. Deleted User

    Deleted User

    Guest

    There's another way to detect 'any' key, here's some code if anyone is interested:

    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.InputSystem;
    3. public class Test : MonoBehaviour
    4. {
    5.     private readonly InputAction anyKey = new(binding: "/*/<button>", type: InputActionType.Button);
    6.     private void Update()
    7.     {
    8.         if (anyKey.triggered)
    9.         {
    10.             print("'Any' button pressed");
    11.         }
    12.     }
    13.     private void OnEnable()
    14.     {
    15.         anyKey.Enable();
    16.     }
    17.     private void OnDisable()
    18.     {
    19.         anyKey.Disable();
    20.     }
    21. }
     
    Nolex and lena_unity458 like this.
  20. moatdd

    moatdd

    Joined:
    Jan 13, 2013
    Posts:
    178
    I had a great dream once. It looked something like this:

    upload_2022-2-1_12-24-37.png
     
    aromana and Deleted User like this.
  21. Deleted User

    Deleted User

    Guest

    This right here.

    And putting an option for 'any' key there as well.


    Btw, the code that's already provided for 'any' key doesn't register D-Pad on Dualsense as "Buttons" for some odd reason .. Oh, and if you press R3 + L3 at once when Dualsense is connected, you get a "weird" stats panel popup. I don't know if this is a bug or meant as something else, but it probably is a bug.

    So far, the Input System still lacks some basic features. I hope they get completed before the sun explodes.
     
    blackmodjo and moatdd like this.
  22. aromana

    aromana

    Joined:
    Nov 11, 2018
    Posts:
    137
    Speaking of lacking features, does the input system include a mobile touch joystick? Like a proper, "just drop it into your project and go" one, not a toy/proof of concept. Obviously I could build it myself, but there are a lot of edge-cases to consider and it's easy to mess up. For example, supporting the joystick "snapping" to the player's finger, restricting to parts of the screen, handling focus issues, etc. Rewired offers this and it's one of the reasons I'm sticking with it despite the new input system offering lots of other Rewired-inspired stuff like input remapping.
     
  23. Konaju-Games

    Konaju-Games

    Joined:
    Jul 11, 2012
    Posts:
    22
    Scroll Up and Scroll Down are not buttons. They're an axis or a value.
     
  24. moatdd

    moatdd

    Joined:
    Jan 13, 2013
    Posts:
    178
    And a gamepad joystick offers separated axes, float values AND discrete buttons which are assignable to user-rebindable commands.

    upload_2022-2-2_5-35-38.png
    So my request is consistent with this.

    Once you try and add functionality to your app where the user can choose to dynamically rebind the scroll up and scroll down inputs to their commands (such as for weapon switching, consumable item switching) you are going to need this too.

    Without the scroll up and down "keys" we can't make use of
    InputAction.PerformInteractiveRebinding(bindingIndex) to rebind actions. So what do you propose in place of this for us to use?

    So let's say we follow your insinuation and leave this vital feature out and read the axis values from the scroll wheel and do the reverse -- that is, to grant people the ability of assigning a command to to a control instead of what the whole world is used to, which is assigning a control to a command.

    I imagine we'll have to have a dropdown option which offers a number of commands to the Scroll Up function and a dropdown option which offers a number of commands to the Scroll Down function.

    And then that binding wouldn't be serializable for storage and retrieval via

    Actions.LoadBindingOverridesFromJson(jsonKeyBinds);

    Actions.SaveBindingOverridesAsJson()


    We'd have to make something new. That is, each and every developer who wants to allow for an assignable scroll wheel. Shall we all find our own bespoke ways of doing this? Or are you trying to make more business for the Asset Store?
     
    Last edited: Feb 2, 2022
    Deleted User likes this.
  25. moatdd

    moatdd

    Joined:
    Jan 13, 2013
    Posts:
    178
    ;) I humbly offer this stopgap workaround for gamepads...
    upload_2022-2-2_5-46-18.png

    ...wait'll you see the one for keyboards!
     
    Deleted User likes this.
  26. Deleted User

    Deleted User

    Guest

    Wow, that was pretty impressive! I never thought of that .. well done! :p

    lol. There's actually one for keyboard. Your action must be set to "Button", and then click on the binding, then select "Keyboard" under "Path" manually, and finally "Any Key".

    Keyboard Any Key.png


    Now, they should do it for Mouse, Gamepad and other devices. And 'any' key that triggers All devices!
     
    moatdd likes this.
  27. Any up/down, left/right, prev/next actions should be constitute an Axis, and should be Axis type. If you do that, then you can rebind your weapon switching to any Axis type controls like mousewheel, any one stick/dpad axis, mouse direction or even twokey-made-up axis.
    It works like this.

    BTW, this whole chasing the true "anykey" also is not a good idea. It is costly in terms of performance and usually there are better alternatives, better UX-design. Unless you want to build a flappy bird clone which truly works with any available, pushable trigger on any device. Change your Mouse to Pointer and you can cover pens too.
     
    SomeGuy22 and moatdd like this.
  28. moatdd

    moatdd

    Joined:
    Jan 13, 2013
    Posts:
    178
    Oh thank goodness. You saved me a lot of typing!!! :D
     
    Deleted User likes this.
  29. moatdd

    moatdd

    Joined:
    Jan 13, 2013
    Posts:
    178
    I'd use it for intro screens or dialogue screens where they say: "press any key to continue..."
    But I suppose some games use: "Press A to begin" or "Press START to begin" or "Press Enter to begin"
     
    Deleted User likes this.
  30. Deleted User

    Deleted User

    Guest

    There you go:

    Shit Post.png
     
    moatdd likes this.
  31. moatdd

    moatdd

    Joined:
    Jan 13, 2013
    Posts:
    178
    I want them to be separated and not conjoined into one axis for user customization purposes because the user may want to:
    • use mousewheel up to swap between their primary and secondary weapons
    • use mousewheel down to switch to their sidearm, or toggle their weapon light, or who knows?
    The problem is that Interactive Rebinding *cannot* capture these individual movements as two separate inputs for two separate arbitrary commands until their respective individual "button inputs" are added.
     
    Last edited: Feb 2, 2022
    Deleted User likes this.
  32. moatdd

    moatdd

    Joined:
    Jan 13, 2013
    Posts:
    178
    :eek: Behold! We are witnessing the energy of a dev's productive desires being redirected by an underlying subsystem bug into unusual places.
     
    Deleted User likes this.
  33. It really isn't rocket science.
    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.InputSystem;
    3. public class Test : MonoBehaviour
    4. {
    5.     private InputAction _anyKeyWait;
    6.  
    7.     private void Awake()
    8.     {
    9.         _anyKeyWait = new InputAction(binding: "/*/<button>", type:InputActionType.Button);
    10.         _anyKeyWait.AddBinding("/<Gamepad>/*/*");
    11.         _anyKeyWait.performed += DoSomething;
    12.     }
    13.  
    14.     private void OnEnable() => _anyKeyWait.Enable();
    15.     private void OnDisable() => _anyKeyWait.Disable();
    16.     private void OnDestroy() => _anyKeyWait.performed -= DoSomething;
    17.  
    18.     private void DoSomething(InputAction.CallbackContext ctx) => Debug.Log("'Any' button pressed.");
    19. }
    Any key (well, button on game pads) doesn't usually mean sticks or pads. Do not mix up technical stuff with proper UX. Just because Unity allows you to treat directions in special cases like buttons, that doesn't mean users do as well. Buttons are buttons: ABXY and maybe the start and system (whatever it's called) on X Box, XO▢△ on PS. The rest are triggers, pads and sticks and whatnot.
     
  34. Deleted User

    Deleted User

    Guest

    D-Pads are directions And Buttons at the same time. They're just like WASD on the Keyboard, they can be used for movement(axes), while still being considered as "Buttons". This is how the Input System works ¯\_(ツ)_/¯
     
  35. I think you should read what I wrote again. I know how the input system works, otherwise I would be asking the questions and you would provide me answers.
     
  36. blackmodjo

    blackmodjo

    Joined:
    May 6, 2014
    Posts:
    14
    yes they are on-screen components, but they are also buggy, basically they don't work once you have a wired Input event system and PlayerInput components, if you don't wire them together all seems to work :D
     
    aromana likes this.
  37. IDK what does that exactly mean, because I don't develop for mobiles (touchscreens), but Unity's starter assets contain a full set of screen controls and they seem to be working (well I only tried to use them with mouse -> not a mobile developer) with PlayerInput and all. Maybe it worth to check it out if you haven't already.
     
    Last edited by a moderator: Feb 2, 2022
    blackmodjo likes this.
  38. Deleted User

    Deleted User

    Guest

    I thought I read it correctly .. since you say:

    Let's take PS Controller since that's what I'm more familiar with .. you say XO▢△ are the buttons, along with "Start" and "Select" at most are considered as such .. then you appended with an exclusion list (the rest are ..), and "pads" is one of them being: not Buttons. Is that what you mean? Or am I missing something?
     
  39. You entered into a discussion about "Press any button to continue..." usage. @moatdd started to handle everything on the technical side (dpad directions are buttons...). I described to him and advised him not to mix up the technical (how the input system works) side of things with the UX side of things (how the users perceive things).
    When you say "button", 99.9% of users will think button like I described: ABXY, XOSquareTriangle (I hate Sony for this.. BTW :D, anyway) and some aux buttons. Triggers, pads, sticks aren't perceived as buttons usually. Totally not worth it to chase after a solution which isn't really needed. This conversation stemmed from my comment about chasing the "true" any-key solution.
    If you tell the user to "press any button to continue" and you react only to ABXYStartWhateverXOSquareTriangle, then the overwhelming majority of the users will understand what you mean and won't miss the option to tilt the stick to continue.

    Is it clear what I mean? (English is only my second language, so sometimes I may miss or misuse certain phrases and it's sometimes important)
     
    Last edited by a moderator: Feb 2, 2022
    Deleted User likes this.
  40. Deleted User

    Deleted User

    Guest

    Yep, now I see the whole picture, very nice explanation. English isn't your first language?? You are really impressive, I thought you were a native! Props to you :D
     
    Lurking-Ninja likes this.
  41. blackmodjo

    blackmodjo

    Joined:
    May 6, 2014
    Posts:
    14
    Thank you, i know there are a lot other options and assets that handle mobile, my point is that the mobile on screen buttons delivered with this package don't work well with the Playerinput also delivered in this package, and Playerinput is forced upon you if you want to handle local multiplayer. If they would work then using the new input system would truly be beneficial since it would definitely close the gap of having to handle multiple input sources, currently it is still something nice to try, but still far from production ready.
     
    Lars-Steenhoff and aromana like this.
  42. stevphie123

    stevphie123

    Joined:
    Mar 24, 2021
    Posts:
    81
    Another way to detect any key presses by getting it from onEvent, this way you can do your own micro optimization if required.

    Also, there is onAnyButtonPress, but this is basically just a thin wrapper for onEvent


    Code (CSharp):
    1.      
    2.  
    3.         m_EventListener = InputSystem.onEvent
    4.         .ForDevice<Keyboard>()
    5.         .Where(e =>
    6.         {
    7.             //if(e.type != StateEvent.Type && e.type != DeltaStateEvent.Type)
    8.             return e.type == StateEvent.Type;
    9.         })
    10.         .Call((ctrl) =>
    11.         {
    12.             if(ctrl.GetAllButtonPresses().Count() == 1)
    13.             {
    14.                 Debug.Log(ctrl.GetFirstButtonPressOrNull().name);
    15.             }
    16.         }
     
  43. BeifongSaeko

    BeifongSaeko

    Joined:
    Apr 9, 2019
    Posts:
    5
    Does gravity & sensitivity have been added from the old input system ? it wasn't the last time i tried the new input system.

    Thank.

     
  44. loconeko73

    loconeko73

    Joined:
    Aug 13, 2020
    Posts:
    17
    I just wanted to say thank you for that, as it was finally the first complete and proper answer to a question I had to implement a "Press a key to continue" functionality.

    Much appreciated, @Lurking-Ninja !
     
  45. CDF

    CDF

    Joined:
    Sep 14, 2013
    Posts:
    1,306
    Anyone else having this issue?
    I can't add devices to control schemes anymore, the popup just hides immediately

    control_schemes.gif

    I have to manually edit the meta

    meta.png
     
  46. MarsCitizen_1

    MarsCitizen_1

    Joined:
    Jun 2, 2016
    Posts:
    20
    The 1.3.0 update introduced several funky things when doing split screen local multiplayer.

    1. Selectables coloring settings goes right in the trash. Disabled vs Normal is not obeyed correctly. Almost everything starts showing up as disabled by default. Happens once you have more than 1 PlayerInput w/ their own canvases.
    2. An issue I'll describe in better detail another time. Again, multiple players, multiple canvases: when new Selectables are instantiated on Player X's canvas, Player Y loses currently selected gameObject in MultiplayerEventSystem and is also unable to navigate back to items in their currently active canvas group.

    These are easy to test out by putting buttons on canvases and joining 2 players, using the full suite of InputSystem tools designed for split screen & distinct canvases & canvas roots per player (PlayerInput, MultiplayerEventSystem, uiInputModule).
     
    LeonidDeveloper likes this.
  47. BinaryRavine

    BinaryRavine

    Joined:
    Oct 30, 2021
    Posts:
    6
    It fixed the "Key being Stuck" issue for windows, but still same for Android (Didn't check on iPhone yet). Some time button stay pressed, although physically there is no one touching the device but input system somehow get stuck, until you tap the stuck button again.
    Please let me know there is any work around for that.
     
  48. LeftyTwoGuns

    LeftyTwoGuns

    Joined:
    Jan 3, 2013
    Posts:
    260
    Does 1.3 have better support for Switch Pro controller or is that going to be in a later update?
     
  49. dmytro_at_unity

    dmytro_at_unity

    Unity Technologies

    Joined:
    Feb 12, 2021
    Posts:
    212
    fullerfusion likes this.
  50. jonkristinsson

    jonkristinsson

    Joined:
    Aug 21, 2014
    Posts:
    2
    Fixed MultiplayerEventSystem not preventing keyboard and gamepad/joystick navigation from one player's UI moving to another player's UI (case 1306361).
    This fix relies on a CanvasGroup being injected into each playerRoot and the interactable property of the group being toggled back and forth depending on which part of the UI is being updated.
    is this fix causing problems for anyone else? Because it's constantly toggling "interactable" my buttons constantly flash between their actual state and disabled state..
     
    MarsCitizen_1 likes this.