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

Input System Update

Discussion in 'Input System' started by Rene-Damm, Dec 12, 2017.

Thread Status:
Not open for further replies.
  1. Rene-Damm

    Rene-Damm

    Joined:
    Sep 15, 2012
    Posts:
    1,779
    1.0.0-preview.5 is out now. Most importantly fixes the kb&mouse control scheme regression introduced in 1.0.0-preview.4. Full changelog here.

    Status-wise, no change to the agenda. We'll keep whittling down the bug pile. I expect we have another package with more fixes in 2 weeks.
     
  2. SteveJP87

    SteveJP87

    Joined:
    Feb 5, 2013
    Posts:
    14
    Is software cursor from the VirtualMouse component supposed to trigger IPointer events?
    If I have selected "Use hardware cursor if available" my IPointer events work, but "Software Cursor" does not.
     
  3. SteveJP87

    SteveJP87

    Joined:
    Feb 5, 2013
    Posts:
    14
    I yoinked the button state change code for my own virtual mouse and I can get all IPointer events to fire.

    The software pointer selection in the new VirtualMouse component however doesn't seem to fire any IPointer event.

    Edit:

    A few more things to note:
    The canvas clamping doesn't work. It seems m_Canvas is null, even after setting a cursor graphic.

    If I manually grab the canvas from the cursor graphic during update and populate m_Canvas the clamping works, but it's coordinate space differs completely from newPosition. This explains why IPointer events aren't going off, the newPosition is not in the correct coordinate space for the canvas.

    See attached picture. The red dot is where the newPosition cursor is at. The magenta box is the true pixel rect location, and the green dot shows where that red dot is in actual canvas space.

    upload_2020-2-14_17-32-30.png
     
    Last edited: Feb 15, 2020
  4. SteveJP87

    SteveJP87

    Joined:
    Feb 5, 2013
    Posts:
    14
    Incase anyone is looking for a quick working virtual cursor:
    You'll need to replace my PlayerInput lines with your control bindings.

    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.InputSystem;
    3. using UnityEngine.InputSystem.LowLevel;
    4.  
    5. public class UICursorWidget : MonoBehaviour
    6. {
    7.     [SerializeField] private RectTransform _canvasTransform = null;
    8.     [SerializeField] private float _cursorSpeed = 0.0f;
    9.     private RectTransform _rectTransform = null;
    10.     private Mouse _virtualMouseDevice = null;
    11.     private Vector2 _virutalMousePosition = new Vector2(0, 0);
    12.  
    13.     public void Awake()
    14.     {
    15.         PlayerInput.Controls.UI.Confirm.performed += _ConfirmOnperformed;
    16.         PlayerInput.Controls.UI.Confirm.canceled += _ConfirmOncanceled;
    17.         Cursor.visible = false;
    18.  
    19.         _virtualMouseDevice = InputSystem.AddDevice<Mouse>();
    20.         _rectTransform = GetComponent<RectTransform>();
    21.         _rectTransform.anchoredPosition = _virutalMousePosition;
    22.         _UpdateMouseMovementState(_virtualMouseDevice, _CalculateRealScreenPosition(), Vector2.zero);
    23.     }
    24.  
    25.     public void Update()
    26.     {
    27.         Vector2 stickInput = PlayerInput.Controls.UI.LeftStick.ReadValue<Vector2>();
    28.         Vector2 stickStep = stickInput * (Time.deltaTime * _cursorSpeed);
    29.         if (stickStep == Vector2.zero) return;
    30.         _virutalMousePosition += stickStep;
    31.         _virutalMousePosition.x = Mathf.Clamp(_virutalMousePosition.x, -_canvasTransform.sizeDelta.x  *.5f, _canvasTransform.sizeDelta.x  *.5f);
    32.         _virutalMousePosition.y = Mathf.Clamp(_virutalMousePosition.y, -_canvasTransform.sizeDelta.y  *.5f, _canvasTransform.sizeDelta.y  *.5f);
    33.         _UpdateMouseMovementState(_virtualMouseDevice, _CalculateRealScreenPosition(), stickStep);
    34.         _rectTransform.anchoredPosition = _virutalMousePosition;
    35.     }
    36.  
    37.     private Vector2 _CalculateRealScreenPosition()
    38.     {
    39.         return _virutalMousePosition * _canvasTransform.localScale + new Vector2(Screen.width * .5f, Screen.height - Screen.height * .5f);
    40.     }
    41.  
    42.     private void _UpdateMouseMovementState(Mouse device, Vector2 position, Vector2 delta)
    43.     {
    44.         InputSystem.QueueStateEvent(device, new MouseState
    45.         {
    46.             position = position,
    47.             delta = delta
    48.         });
    49.     }
    50.  
    51.     private void _UpdateMouseButtonState(MouseButton button, bool isPressed)
    52.     {
    53.         _virtualMouseDevice.CopyState<MouseState>(out var mouseState);
    54.         mouseState.WithButton(button, isPressed);
    55.         InputState.Change(_virtualMouseDevice, mouseState);
    56.     }
    57.  
    58.     private void _ConfirmOnperformed(InputAction.CallbackContext obj)
    59.     {
    60.         _UpdateMouseButtonState(MouseButton.Left, true);
    61.     }
    62.  
    63.     private void _ConfirmOncanceled(InputAction.CallbackContext obj)
    64.     {
    65.         _UpdateMouseButtonState(MouseButton.Left, false);
    66.     }
    67. }
     
    Last edited: Feb 15, 2020
  5. SteveJP87

    SteveJP87

    Joined:
    Feb 5, 2013
    Posts:
    14
    Final find:
    The virtual mouse script does *not* work with UI Scale Mode set to Scale With Screen Size.
    Constant Pixel Size works fine, but it won't scale with the screen size setting.
     
  6. overbuilt

    overbuilt

    Joined:
    Jan 3, 2014
    Posts:
    14
    Seems newest version from git fixed the problem.

    BTW: Where can I get package with Nintendo Switch console support?
    EDIT: I found package on Nintendo forums, works great :)
     
    Last edited: Feb 17, 2020
  7. Tigersong

    Tigersong

    Joined:
    Aug 11, 2014
    Posts:
    73
    The package is imported, and yet "InputSystem is not part of the namespace UnityEngine".
     
  8. Lightzer

    Lightzer

    Joined:
    Jun 23, 2018
    Posts:
    5
    If you're using multiple assemblies, you have to add the UnityEngine.InputSystem assembly to the dependencies
     
  9. VOTRUBEC

    VOTRUBEC

    Joined:
    Dec 17, 2014
    Posts:
    106
    Hi Rene-Damn,

    You and I spoke last year about the fact that the Touch isn't able to interact with IMGUI. My only concern is if I start using and promoting the new Input System, am I going to have a lot of angry people tell me that things such as Ads don't work? Even setting the Active Input Handling to "Both" doesn't seem to fix the issue. On that note, and please, please excuse my ignorance on the matter, no matter how much I searched, I couldn't actually find anything out about how ads are handled. You know, the ones that are supplied for all the casual games and are usually mini-games themsevles. Are they built as native views on top of the Unity game, or are they part of Unity, and if so, are they using the Input Manager (Old) handler? If I chose one handler over the other, will the Ads still work regardless? I'd really rather avoid publishing a fake game just to test out if the ads work. This comes about because I first noticed that the Test Unity Ads didn't work, because the test page was using IMGUI.

    Anyway, if you get a chance to respond, I'd be happy to hear what the future there is.

    TL;DR At what point can I "safely" move to the new Input System for touch devices, with IMGUI working?

    Cheers.
     
    tarahugger likes this.
  10. Tigersong

    Tigersong

    Joined:
    Aug 11, 2014
    Posts:
    73
    Thanks! Add it to the project's dependencies, you mean? How?
     
  11. Extrys

    Extrys

    Joined:
    Oct 25, 2017
    Posts:
    343
    Im having errors with the input system, im adding an axis as a button
    upload_2020-2-23_16-3-56.png
    Climb is Button

    And it just fires one time
    no more than once, whats happening here?

    But other buttons are working correctly,
    i have this
    upload_2020-2-23_16-5-21.png
    is a pass through Button with hold interaction and it works correctly

    I need my triggers to work like buttons, what im doing wrong?
     
  12. ROBYER1

    ROBYER1

    Joined:
    Oct 9, 2015
    Posts:
    1,450
    @Rene-Damm The 'Listen' feature for input bindings doesn't seem to work for XR devices in our testing so far, it won't pick up anything from the XR device! Do I need to report this as a bug? I spend hours of every day reporting bugs with the Editor and listening for XR inputs seems rudimentary.
     
  13. Darkon_Who

    Darkon_Who

    Joined:
    Jul 22, 2017
    Posts:
    14
    Hey @Rene-Damm Any idea why when i use a InputSystemUIInputModule with the PlayerInput script, then UI navigation stops working altogether? This is on the latest available version 1.0.0-preview.5

    upload_2020-2-25_18-48-49.png

    Please help!
     
  14. Jichaels

    Jichaels

    Joined:
    Dec 27, 2018
    Posts:
    237
    If it didn't change, there was a bug that if you use the same input asset in the player input AND the ui module, it wouldn't work. Just assign the default asset input to the ui module or create a new one and it should work
     
    Twin-Stick likes this.
  15. colinday

    colinday

    Joined:
    Jan 9, 2012
    Posts:
    25
    I seem to remember reading buried in some post which Unity versions the new input system was and wasn't currently compatible with but can't find it now. Can we get a pinned post with that status or point me to where I might otherwise find it?
     
    ROBYER1 likes this.
  16. Deozaan

    Deozaan

    Joined:
    Oct 27, 2010
    Posts:
    707
    Technically only officially supported for 2020.1+ but with a stated goal of being compatible with 2019.3 as well.

    Sources:
    https://forum.unity.com/threads/input-system-update.508660/page-15#post-5190779
    https://forum.unity.com/threads/input-system-update.508660/page-14#post-5146007
     
    Last edited: Feb 27, 2020
    colinday and ROBYER1 like this.
  17. ROBYER1

    ROBYER1

    Joined:
    Oct 9, 2015
    Posts:
    1,450
  18. Darkon_Who

    Darkon_Who

    Joined:
    Jul 22, 2017
    Posts:
    14
    This did not work unfortunately :( It just forces me to use the Input that the PlayerInput component is using.

    @Rene-Damm Can you please assist this is becoming a real blocker for me.

    EDIT: One thing i noticed now is that in a fresh project everything seems to work fine? HMMM :(

    EDIT 2: Also noticed that even in a fresh project, mouse and keyboard dont seem to do anything as well. Only have controller working so far, even though my own its on my own version of the DefaultUI actions or not
     
    Last edited: Mar 1, 2020
  19. Rene-Damm

    Rene-Damm

    Joined:
    Sep 15, 2012
    Posts:
    1,779
    There's no plans for supporting IMGUI with the input system. At this point, IMGUI in the *player* (not in the editor) is considered legacy. We will support both uGUI (already happending) and UI Elements (coming later this year) in the player with the input system.

    That said, any Unity functionality that depends on IMGUI to work properly in the player, we obviously need to fix and make work when using the input system. So, I encourage you to file a ticket and shout loudly at us to get this fixed :)

    This is an unfortunate limitation with how the XR stuff (currently) works. XR devices only exist in play mode so when the game isn't playing, the input system simply won't see any input from those and thus the "Listen..." functionality is broken.

    Obviously, this isn't great. As far as filing a bug goes, absolutely, do it :)

    Is this still a blocker? If so, please file a ticket and shout at me.
     
  20. Rene-Damm

    Rene-Damm

    Joined:
    Sep 15, 2012
    Posts:
    1,779
    1.0.0-preview.6 is out. Changelog as usual is here.
     
    karl_jones likes this.
  21. Player7

    Player7

    Joined:
    Oct 21, 2015
    Posts:
    1,533
    Does this input system have any additional package like https://guavaman.com/projects/rewired/docs/ControlMapper.html for ugui? I think you did some video a while back and the functionality for control remapping seemed a bit..well not all that great from what I remember at the time. Is there a roadmap on the new input stuff getting to stage where it would be good to move things onto it?
     
  22. Rene-Damm

    Rene-Damm

    Joined:
    Sep 15, 2012
    Posts:
    1,779
    1.0.0-preview.4 landed some improvements to that part which hopefully makes the whole thing a lot less raw. There's a rebinding screen sample that has a reusable MonoBehaviour and a prefab. Doubt we're quite at Rewired's level yet but should be a whole lot better compared to what was there before.
     
  23. Luminoth

    Luminoth

    Joined:
    Jan 15, 2013
    Posts:
    25
    So I just updated to preview.6 and I'm getting an error "'InputSystemUIInputModule' does not contain a definition for 'EnableAllActions'" (and the same for DisableAllActions). I don't see anything in the release notes about that changing, so I'm wondering if maybe I'm doing something wrong here? Basically whenever my game enters a "UI input" state (like main menu or pause menu for example) I would call EnableAllActions() on my InputSystemUIInputModule and then DisableAllActions() when exiting this state.

    I do have an issue with this setup currently where only a single gamepad can actually do UI input when the actions are enabled, so I suspect I'm just doing this incorrectly. So I guess, what is the proper way to handle it?

    EDIT - Tho it appears to work just fine if I remove those calls completely. Now I really think I'm doing something wrong...
     
  24. sbutterworth

    sbutterworth

    Joined:
    Jan 28, 2020
    Posts:
    5
    Hello.

    I am using version 2019.2.9f1 and I just updated our project to use the new input system. I followed the examples of using events and it all seems to work great. Having support for multiple input schemes is fantastic.

    The one issue I am having is, we typically run multiple copies of our game on a local machine when testing (its a multiplayer game). With the old system I could control multiple clients with the same game pad since the input only affected the client that had focus. With the new input system, all clients are reacting to the single input device. I suspect I missed something when watching the videos and reading the examples. How can I limit the input to the instance that has focus?

    Sean
     
  25. Schubkraft

    Schubkraft

    Unity Technologies

    Joined:
    Dec 3, 2012
    Posts:
    1,070
    I tried to reproduce this (using latest 2019.3.4) and can't manage to get the same behaviour. Could you be so nice to send a bug report with a repro project?
     
  26. Thomasedu

    Thomasedu

    Joined:
    Apr 9, 2018
    Posts:
    1
    Hi @Rene-Damm, is there any way now to make a 4 multiplayer gamepads setup?

    The input manager comes with de Joining Behavior, but it always spawn the same prefab. So i've tried a thing you said, setting an action map for each game pad, but the player controling the prefab with the GAMEPADS bidings controls, always controls the others players with gamepads bidings.

    So for testing my game, i had to put an action map with a xbox binding, one with the keyboard binding and the other with dualshock 4. So i can set up just 3 players with difertent types of controlers each.

    Another things is the UI, i combined the Multiplayer Event System with the Input System UI Module, so each canvas is controled by one gamepad, but if i navigate between the buttons in a panel, the other player can navigate througth the other player canvas.
     
  27. sbutterworth

    sbutterworth

    Joined:
    Jan 28, 2020
    Posts:
    5
    I created a sample project using 2019.3.4f1 and was able to repro the problem. Bug submitted (Case 1227077)
     
    Schubkraft likes this.
  28. Remer

    Remer

    Joined:
    Mar 24, 2013
    Posts:
    78
    After updating to the preview.6, I get the following error and I can't commit the changes (unity 2019.3.5)
     

    Attached Files:

  29. Schubkraft

    Schubkraft

    Unity Technologies

    Joined:
    Dec 3, 2012
    Posts:
    1,070
    You can ignore the files from packages, you just need the manifest. How did it work in previous updates when files got added to the package?
     
  30. Remer

    Remer

    Joined:
    Mar 24, 2013
    Posts:
    78
    Usually when i update a package, collab detects changes only to the manifest (i think because packages folder is not considered). In this case it didn't happen.

    By the way, i remove the package and reinstalled and it works.
     
  31. Foulcloud

    Foulcloud

    Joined:
    Mar 23, 2014
    Posts:
    19
    Using Preview.3-1.0.0, I was able to receive mouse scrolls for rebinding. This no longer seems to work in Preview.6-1.0.0. I have tested that I can hard code an action with a mouse scroll input and it still works fine. However I am never able to get them to register when attempting a rebinding. Rebinding seems to work fine for all other buttons/keys.

    Here is my rebinding code which worked fine before:

    Code (CSharp):
    1. m_RebindOperation?.Dispose();
    2.         m_RebindOperation = m_Action.PerformInteractiveRebinding()
    3.             .WithCancelingThrough("<Keyboard>/Escape")
    4.             .WithControlsExcluding("<Mouse>/position")
    5.             .WithControlsExcluding("<Mouse>/delta")
    6.             .WithControlsExcluding("<Mouse>/radius")
    7.             .WithControlsExcluding("<Keyboard>/printscreen")
    8.             .OnCancel(
    9.             operation => {
    10.                 ButtonRebindCompleted();
    11.             })
    12.             .OnMatchWaitForAnother(0.1f)
    13.             .OnComplete(operation => ButtonRebindCompleted());
    14.         m_RebindOperation.Start();
     
  32. remption

    remption

    Joined:
    Jun 1, 2014
    Posts:
    10
    I just started working on similar issues for my team's game as we try to update. Right now, it looks like you're going to have to dig into the code. It's not too hard to achieve, though, as there are a lot of ways to start tracking devices + limit which devices an action/actionmap listens to.

    I've ditched the joining script and made my own. I start with tracking players' InputDevices from the main menu.
    Player1's device is whatever is used to press the "start" button on the start screen.
    Then, they can open a "roster" menu. Once it's open, other players can press a button on their device and confirm to join.

    You could always keep the default joining script instead, and have it spawn a very basic player prefab. This prefab could, on enable, open a menu for the new player to pick details like what sort of character specifically they're playing...

    Basically, there's nothing perfect out of box (afaik), but there are loads of ways to work around it with varying levels of programming.
     
    Last edited: Mar 15, 2020
  33. sbutterworth

    sbutterworth

    Joined:
    Jan 28, 2020
    Posts:
    5
    Hello.

    I am using version 2019.2.9f1 and I have found that the screen orientation feature on Android builds has stopped working after switching to the new input system. Our application will not change the orientation anymore when the phone is rotated. In code we have something like:
    Screen.autorotateToPortrait = true;
    Screen.autorotateToPortraitUpsideDown = true;
    Screen.autorotateToLandscapeLeft = true;
    Screen.autorotateToLandscapeRight = true;
    Screen.orientation = ScreenOrientation.AutoRotation;
    which basically seems to have no effect anymore. We are using EnhancedTouchSupport.
    Is there something extra that needs to be setup for this to work correctly?
     
  34. AmazingRuss

    AmazingRuss

    Joined:
    May 25, 2008
    Posts:
    933
    I am trying to capture mouse delta, and it works, but allocates crazily and kills framerate.
    Have I done something evil in the way I set up the actions?
     

    Attached Files:

  35. Schubkraft

    Schubkraft

    Unity Technologies

    Joined:
    Dec 3, 2012
    Posts:
    1,070
    Can you submit a bug report via the editor please ideally attach a repro project showing what it you are doing.
    Thanks!
     
  36. Alesk

    Alesk

    Joined:
    Jul 15, 2010
    Posts:
    339
    For some reason I have to separate the gameobject receiving the UserInput component and the InputSystemUIInputModule component.

    My code is looking like this :
    Code (CSharp):
    1. PlayerInput input = playerController.GetComponent<PlayerInput>();
    2. input.uiInputModule = this.GetComponent<InputSystemUIInputModule>();
    playerController is referencing the other gameObject having the PlayerInput component.

    On the second line, I apply the uiInputModule to this PlayerInput, and I get this warning message in the console :

    Actions used with the UI input module should generally be set to Pass-Through type so that the module can properly distinguish between input from multiple devices (action UI/Navigate[/XInputControllerWindows/leftStick,/XInputControllerWindows/dpad] is set to Value)
    UnityEngine.InputSystem.PlayerInput:set_uiInputModule(InputSystemUIInputModule)

    I don't clearly understand what I should fix and where ... someone have an idea please ?
     
  37. Alesk

    Alesk

    Joined:
    Jul 15, 2010
    Posts:
    339
    I've found it !

    I had to click on the action name, and then on the action type !
    I've put it on every action in my UI action maps, and the warning is gone... And everything is still working properly ;)
     

    Attached Files:

  38. AmazingRuss

    AmazingRuss

    Joined:
    May 25, 2008
    Posts:
    933
    Well, that was interesting... Tried to make a repro project with the InputAction asset... no problems. So I went back to my project that was having the problem, and ran an empty scene. FPS still dropping below 30 when I wiggle the mouse.

    So I deleted the Library folder (getting to be a regular occurrence), and now everything's fine.

    Not very satisfying, I know, but that's all I got.
     
  39. Schubkraft

    Schubkraft

    Unity Technologies

    Joined:
    Dec 3, 2012
    Posts:
    1,070
    Thanks for trying though and please don't hesitate to post further feedback :)
     
  40. remption

    remption

    Joined:
    Jun 1, 2014
    Posts:
    10
    Hey! Just a heads up, and not sure if this is intended or not, but in preview 6:

    At runtime, PlayerInput can't restart auto-switching between unpaired devices. IE, if you have autoswitching enabled, and go:
    Code (CSharp):
    1. m_playerInput.neverAutoSwitchControlSchemes = true;
    2. //stops autoswitching
    3. ....
    4. m_playerInput.neverAutoSwitchControlSchemes = false;
    5. //should begin auto switching once more, but does not
    If I call PlayerInput.Disable() and then PlayerInput.Enable(), I think it will start autoswitching again. Is that what we're expected to do?

    The alternative: I found PlayerInput's setter for neverAutoSwitchControlSchemes can only stop autoswitching, not start it again, at runtime. I gave it the ability to restart auto switching:

    Code (CSharp):
    1.  public bool neverAutoSwitchControlSchemes
    2.         {
    3.             get => m_NeverAutoSwitchControlSchemes;
    4.             set
    5.             {
    6.                 if (m_NeverAutoSwitchControlSchemes == value)
    7.                     return;
    8.                 m_NeverAutoSwitchControlSchemes = value;
    9.  
    10.                 if (m_Enabled) {
    11. //this is new
    12.                     if (value) StartListeningForUnpairedDeviceActivity();
    13.                     else
    14.                         StopListeningForUnpairedDeviceActivity();
    15.                 }
    16.             }
    17.         }
    Now it works without having to call PlayerInput.Disable() and PlayerInput.Enable().

    Would this edit have unintended consequences? Bad idea? Wasn't sure, but it seemed odd that I couldn't restart autoswitching by simply changing the bool value, so just wanted to put that out there.
     
  41. Rene-Damm

    Rene-Damm

    Joined:
    Sep 15, 2012
    Posts:
    1,779
    Could you file a ticket for that with the Unity bug reporter? Think it definitely should allow toggling the property on and off on the fly.
     
    remption likes this.
  42. remption

    remption

    Joined:
    Jun 1, 2014
    Posts:
    10
    Will do!
     
    Rene-Damm likes this.
  43. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,617
    I've recently converted a large project from using Rewired to using the new InputSystem. The experience was generally positive, so thumbs up there.

    I'm going to dump all of my feedback here in case any of it us useful. Please don't see any of this as complaining. I would already recommend that people use this system once it comes out of preview. :)
    • When adding an InputAction, if the action goes below the visible part of the list you need to scroll down before you can type the name, even though it is the focused element. Auto-scrolling so the action you just added is visible would be good, as would allowing typing into off-screen elements.

    • Each instance of the auto-generated wrapper class creates its own copy of a not-insignificant asset, from a giant string... Since it's auto-generated and thus we shouldn't be mucking with it, it would be good if all instances of the class could share one static copy of the data structure.
    • Note: That asset is currently fully public, if I remember correctly? Read access to it is important for when you need to look an InputAction up by name, but it should probably be read only.

    • When there are many InputActions, having all of the text for the actions and the bindings and paths formatted the same way makes it harder to read than it could be. The coloured bars help, but I think more could be done. If this were my UI I'd try different formatting for the InputAction names, or adding a little vertical space at the end of an InputAction. This is because I'm often reading down the list looking for a particular thing, and I'm looking down the middle of the text rather than at the bars to the side.

    • The documentation section "Migrating from the old input system" is a bit of a data dump. The list of API equivalents is really useful, but I think other things could help, too. It would have been useful to me if there were a more specific guide for my use case, eg: "Swap Input axis and button polling from Input to InputSystem". Of course not everyone is doing something equivalent to that, so you'd need multiple different ones of those to cover other common use cases. (I know that ideally people won't just go for the polling. That was our first step as it allowed us to move over with minimal changes to our existing, tested code.)

    • It'd be great if there's a built-in way to adjust mouse sensitivity and toggle mouse input on/off. It could be that this exists and I just missed it? For now I split the mouse input into its own action, and apply in-game settings when I use it. No big deal, but the new system is so close to doing that for me...

    • Changing things in the InputActions asset editor causes a code recompile when the wrapper asset is updated. This is a pain in play mode, so it'd be great if re-generating the wrapper could be deferred until you're not in play mode. (For now I just won't hit Save Asset until later, but it'd be nice not to have to remember that.)

    • It took me a few moments to realise that you could use .triggered on an InputAction just bound to an axis to test when it has passed the default actuation point. Before that I was trying to figure out how to look up the actuation point in code.

    • For our tutorial section we're looking up actions via their names. This is pretty easy to do, but for the sake of completeness instructions on how to do that could be added to the migration page (if they're not already there).
    For what it's worth, the main reason we're swapping from Rewired is just to reduce 3rd party dependencies. However, the workflows and integration of the new InputSystem are a bit nicer.
     
    Last edited: Mar 29, 2020
    valentingurkov likes this.
  44. Iron-Warrior

    Iron-Warrior

    Joined:
    Nov 3, 2009
    Posts:
    838
    Getting extremely bizarre behaviour with hold actions and XR controllers (using the Oculus Touch CV1). Using the following:

    Code (CSharp):
    1. using UnityEngine;
    2.  
    3. public class TestInputHold : MonoBehaviour
    4. {
    5.     HoldTestActions testActions;
    6.  
    7.     private void Start()
    8.     {
    9.         testActions = new HoldTestActions();
    10.         testActions.Enable();
    11.  
    12.         testActions.Test.Test.started += (ctx) => Debug.Log("Start!");
    13.         testActions.Test.Test.canceled += (ctx) => Debug.Log("Cancelled!");
    14.         testActions.Test.Test.performed += (ctx) => Debug.Log("Performed!");
    15.     }
    16.  
    17.     private void FixedUpdate()
    18.     {
    19.         //float f = testActions.Test.Test.ReadValue<float>();
    20.         //Debug.Log(f.ToString("F4"));
    21.     }
    22. }
    23.  
    If you have an action set mapped with a hold interaction (default parameters) and a normal button like space bar, it all prints correctly. However, if you use
    <XRController>{RightHand}/primaryButton
    , after the input is performed, it will no longer be possible to start/perform the action again. So you could spam the button a bit and get

    Code (CSharp):
    1. Start!
    2. Cancelled!
    3. Start!
    4. Cancelled!
    5. Start!
    6. Cancelled!
    But once it is performed successfully, it will no longer work...note that "Cancelled!" will get printed when the editor is stopped. I'd file a bug report, but I might take a look into the source tonight to see if it's a one line fix.

    Link to actions.
     
  45. Rene-Damm

    Rene-Damm

    Joined:
    Sep 15, 2012
    Posts:
    1,779
    Could you file a ticket with the Unity bug reporter? Definitely sounds strangely broken and we should take a look.

    Super useful feedback. Much appreciated.

    Indeed. Fixed :)

    This one's intentional. The thinking here is that
    • In the majority of cases, there will only be a single instance.
    • When there are multiple instances, duplicating the data fully leads to a much simpler setup (both in the API and in the implementation) than splitting the data up.
    • The duplicated data comprises a relatively low number of objects.
    This rationale led to the decisions of making InputActionAssets different from most other assets like sounds and meshes where you have the opposite situation (multiple uses of the same data are extremely common).

    However, it embedding the JSON string from the aset instead of just generating code that directly creates the asset is something on my list to change. Not happy with that part.

    Agree. We experimented with several different variations and compromised on the current form. There's definitely room for a improvement there. Added a TODO.

    Agree. Think the same shortcomings that are visible right now in much of the input system docs are even more visible in that page. I very much hope that we can substantially improve the situation here after 1.0 final. Either way, added a backlog item specifically for overhauling that page (ISX-345). Think the API dump should move to a subpage and there should be a proper manual page for how to migrate.

    This one's on the list for after 1.0. I think a mouse sensitivity setting is the minimum. Ideally, I'd still like to have InputUserSettings (it exists as a deactivated WIP in the code) that provides a full roster of all the standard input settings (inverted stick axes, inverted mouse axes, mouse sensitivity, custom bindings, and so on) fully functional and providing a sort of one-stop solution for applying common customizations.

    Indeed, it's painful. Didn't use to be the case but then we switched over to making the generated C# code entirely self-contained (rather than referencing the asset file) so now it just re-generates all the time. Not sure what a good solution would look like (it's a bit more complicated due to it being tied into asset importing) but made a backlog item for it (ISX-346).

    Noted :)
     
    angrypenguin likes this.
  46. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,294
    What is the state of rebinding?

    I'm thinking that the docs should have a top-level thing for "this is how you rebind a key in-game. This is how you save and load rebinds from file". I know that rebinding features exist, as they're talked about here and there, but I haven't seen any links.
     
    Last edited: Mar 30, 2020
  47. Awarisu

    Awarisu

    Joined:
    May 6, 2019
    Posts:
    215
    It seems that the current preview package plays nicely with scene/domain reload disabled (as in, no more deluge of exceptions). I didn't see this being called out in the changelog (just some things disappearing) but thanks for fixing it and I'm just letting other readers know that you can try and disable those settings now.
     
  48. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,617
    Thanks @Rene-Damm!

    Oh, another thing:
    • When you're adding InputActions, you can't re-order them by dragging them around while the InputAction above/below the intended destination is open. The UI interprets that you're trying to drag the action into a binding slot, which doesn't work.
    In that context, what's the purpose of having us explicitly enable the object? My interpretation of the design is that it was intentional for us to have multiple instances and enable/disable each one as their relevant objects want input.

    I must admit that I'm super curious as to why this is the case. It seems really odd to me, considering that all the data is already right there in the asset. I'm only a few hours in, so I assume there's a good reason and I just haven't run into it yet.

    For players, yes, but I was actually thinking about Editor workflows.

    Depending on the type of game you're making I can think of 4 desirable mouse behaviours when entering play mode:
    1. For games that use the pointer as a pointer, or don't use it, leave it alone. Do nothing.
    2. If mouse movement is a direct input (eg: aiming in a shooter) and the developer wants to use it by default then the cursor should be locked and hidden when entering play mode. Otherwise, mouse movement as you're testing can interfere with the Editor.
    3. If mouse movement is a direct input but the developer doesn't want the game to grab control then the game should ignore mouse movement until you tell it not to. Otherwise, interaction with the Editor interferes with the game you're testing.

    For both 2 and 3, a key to toggle mouse focus between the game view and the rest of the Editor is important.

    We're working on a game primarily played with a gamepad, but which now has new and shiny mouse support added. Hooking up mouse InputActions was trivially easy, but then I had to add a little extra code to make things not suck when I hit play mode. I recall writing basically the same code for lots of different projects over the years. Giving me a selection of the above 3 behaviours in the InputSystem somewhere would be sweet.

    Edit: Thinking of other cases, there's a 4th - confine the mouse to the Game view. Particularly relevant for games like RTSs where the edge of the screen is a control zone.

    This sounds great. We'd already implemented all of that so I deliberately didn't want to have the InputSystem do that for us for now, but for future stuff that would be excellent. "Can I flip the axes?" is one of the first questions I get asked when doing any kind of large-scale testing with just about any new project, so being able to just put it on a GUI button would be marvellous.
     
    JoNax97 likes this.
  49. Iron-Warrior

    Iron-Warrior

    Joined:
    Nov 3, 2009
    Posts:
    838
    Done, Case 1232006.
     
    Rene-Damm likes this.
  50. Nate6

    Nate6

    Joined:
    Mar 10, 2017
    Posts:
    2
    I am have an out of index out of range error when trying to listen for unpaired devices. Has anybody else encountered this?
     
Thread Status:
Not open for further replies.