Search Unity

Unity Feedback wanted : new Input system support

Discussion in 'UI Toolkit' started by antoine-unity, Sep 2, 2020.

  1. antoine-unity

    antoine-unity

    Unity Technologies

    Joined:
    Sep 10, 2015
    Posts:
    475
    In 1.0.0-preview.8 we have made the Event System component compatible with the new Input System.

    By default, UI Toolkit’s runtime event loop relies on IMGUI events and the legacy Input Manager to get its data. However, Unity now offers a way for users to use a new Input System paradigm, through the com.unity.inputsystem package, and an option to disable use of the legacy Input Manager completely.





    Since Unity encourages its users to try out the new Input System paradigm whenever possible, we want UI Toolkit to offer a graceful, out-of-the-box integration with that system. For our first stable version of the UI Toolkit runtime EventSystem component, we want our users to have a single component that automatically detects which Input System paradigm is in use and connects its event loop to the appropriate underlying data.

    The EventSystem Component

    Default implementation (with old Input Manager)

    Up to release 1.0.0-preview.6, the only way for UI Toolkit runtime users to receive events was through the EventSystem component, which allowed them to remap a few of the standard input sources through InputManager axis and button names.





    Starting from release 1.0.0-preview.8, users are now able to continue using UI Toolkit when the legacy Input Manager is disabled. We implemented an Input System-based version of the EventSystem component, swapping the implementation under the hood and providing a tailored custom Inspector, to make the user’s transition to the new Input System as transparent as possible.

    Note that the component is exactly the same, no user action is required to replace one by the other, and the new Input System version is automatically chosen whenever the new Input System is available, i.e. both the package is detected and the Player Settings input mode is set to anything other than “Input Manager (Old)”.

    In the code, a combination of UNITY_INPUT_SYSTEM and ENABLE_INPUT_SYSTEM compilation flags are tested to enable the sections that apply to the new Input System.

    New Input System implementation




    This version of component is inspired by the Input System implementation of UGUI’s Input Module (https://docs.unity3d.com/Packages/c....InputSystem.UI.InputSystemUIInputModule.html).

    The emphasis is on the Input Action Asset field which serves as a starting point for configuring all the various input actions in accordance with the new Input System paradigm. Actions that aren’t configured can be left to “None”, in which case the action will never occur.

    Once the Input Action asset is configured, a number of standard UI Toolkit actions can be directed to this asset:
    • Navigate is a Vector2 input equivalent to the “Horizontal“ and “Vertical” axes in the regular Event System. So are Submit and Cancel.
    • The Tab action offers a way to remap what input drives the focus navigation towards the next or previous focusable element of the Panel.
    • The Point action triggers PointerMoveEvents
    • The Click, Middle Click and Right Click actions trigger PointerDownEvents and PointerUpEvents, according to their “pressed” state
    • The Scroll Wheel action triggers WheelEvents

    The other fields are:
    • Repeat Delay: Delay in seconds before a navigation or keyboard event starts repeating if input control is held down.
    • Repeat Rate: Delay in seconds between successive repeated navigation or keyboard events after the first one.
    • Fallback on IMGUI Keyboard Events: Enable this to get KeyDown and KeyUp events directly from IMGUI Event queue for maximal backwards compatibility.

    Note that future versions of the UI Toolkit package may invalidate the serialization format of the new EventSystem component and lead to some loss of user configuration, until the component adopts a more permanent serialization convention. The current version relies heavily on the use of #if to detect the new Input System package, and may not retain any of the configurations from the regular EventSystem component when the internal implementation and custom inspector are replaced.

    ---

    Unblocking users already working with the new Input System was primary goal, but we're curious to hear about what you'd expect to see from a UI Toolkit and Input System integration.
     
  2. SoonTofu

    SoonTofu

    Joined:
    Jul 14, 2020
    Posts:
    3
    Hi, Thank you for updating UI Toolkit to work with the new input system. I just tried out `1.0.0-preview.8` and noticed that UGUI is still receiving touches even though I have a UI Toolkit button on top of the UGUI. Is this expected or will this be fixed in a future release?
     
  3. antoine-unity

    antoine-unity

    Unity Technologies

    Joined:
    Sep 10, 2015
    Posts:
    475
    Hello,

    Coexistence with UGUI is not something we have looked at yet. Can you tell us more about this use case? How would you expect to control the priority between the two systems?
     
  4. SoonTofu

    SoonTofu

    Joined:
    Jul 14, 2020
    Posts:
    3
    We are hoping to leverage both UGUI and UITK (UI Toolkit) simultaneously since UGUI still has a lot of animation abilities that we would like to use. We plan to have both UGUI popups and UITK popups or a hybrid popup that uses both UGUI and UITK for parts of the popup where we need more advanced animation features. An ideal system would be if the UITK element processes a touch but will not propagate to the UGUI layer.
     
    laurentlavigne likes this.
  5. Chris-Trueman

    Chris-Trueman

    Joined:
    Oct 10, 2014
    Posts:
    1,023
    I've setup UITK and new Input system on 2 different projects.

    The first project was already setup to use the new input system. It had some issues with the event system, I couldn't select any actions. I had to restart the editor to get it to allow me to set the event system up. After which it doesn't accept any input on anything I try. I've tried uninstalling/reinstalling the runtime api and it keeps giving me the same problem I stated above. Not sure how to fix this one, going to keep trying different things to see if I can. As a side note the project was already using uGUI.

    With the above issues, I started another project. Once I had everything setup, anything in the editor using UITK didn't render correctly. Restarting the editor didn't fix the issue, I had to switch back to the old input, then switch to the new input, after that everything rendered correctly and input worked at runtime.
     
  6. antoine-unity

    antoine-unity

    Unity Technologies

    Joined:
    Sep 10, 2015
    Posts:
    475
    Hello,

    Would you mind giving us the combination of versions of Unity, UI Toolkit and Input System that you are using?
     
  7. Chris-Trueman

    Chris-Trueman

    Joined:
    Oct 10, 2014
    Posts:
    1,023
    I am using Unity 2020.1.5, UIToolKit 1.0 preview 8 and the Input System is 1.0.
     
  8. antoine-unity

    antoine-unity

    Unity Technologies

    Joined:
    Sep 10, 2015
    Posts:
    475
    I've tried this exact version cocktail and I am not observing any rendering issues. Please do submit a bug so we can have access to screen shots, logs, etc.
     
  9. LudiKha

    LudiKha

    Joined:
    Feb 15, 2014
    Posts:
    131
    The input system integration into the EventSystem is great, though there are some serious issues in runtime.

    This is me interacting with a Slider control:

    upload_2020-9-21_17-16-4.png

    Using the latest UIToolkit and the latest Input System.
     
  10. uMathieu

    uMathieu

    Unity Technologies

    Joined:
    Jun 6, 2017
    Posts:
    294
    @LudiKha Thanks for letting us know! This needs to be addressed real soon.

    Can you file a bug report using Help->Report a Bug... That will let us both track the issue and its fix.
     
    LudiKha likes this.
  11. LudiKha

    LudiKha

    Joined:
    Feb 15, 2014
    Posts:
    131
    Alright, I just submitted the report. Also verified this occurs in any fresh project.
     
    benoitd_unity and uMathieu like this.
  12. Lance-Grooms

    Lance-Grooms

    Joined:
    Mar 24, 2016
    Posts:
    21
    I'd love to use the new input system. I've tried preview-8 and preview-9 in conjunction with 2020.1.6f1 / 5.f1 / 1.2f1 (all combinations I believe). 2020.2.0b4 does not forward-upgrade properly and the recommended 2020.2.0b2 is no longer available for download.

    In the above configurations, installing the Input 1.0 package results in this:
    upload_2020-9-29_12-44-34.png

    Manifest for above (w/ 2020.1.6f1):
    Code (CSharp):
    1. {
    2.   "dependencies": {
    3.     "com.unity.addressables": "1.8.5",
    4.     "com.unity.collab-proxy": "1.3.9",
    5.     "com.unity.ide.rider": "2.0.7",
    6.     "com.unity.ide.visualstudio": "2.0.3",
    7.     "com.unity.ide.vscode": "1.2.2",
    8.     "com.unity.inputsystem": "1.0.0",
    9.     "com.unity.mobile.android-logcat": "1.1.1",
    10.     "com.unity.render-pipelines.universal": "8.2.0",
    11.     "com.unity.test-framework": "1.1.16",
    12.     "com.unity.textmeshpro": "3.0.1",
    13.     "com.unity.timeline": "1.4.0",
    14.     "com.unity.ugui": "1.0.0",
    15.     "com.unity.ui": "1.0.0-preview.8",
    16.     "com.unity.ui.builder": "1.0.0-preview.7",
    17.     "com.unity.visualeffectgraph": "8.2.0",
    18.     "com.unity.modules.ai": "1.0.0",
    19.     "com.unity.modules.androidjni": "1.0.0",
    20.     "com.unity.modules.animation": "1.0.0",
    21.     "com.unity.modules.assetbundle": "1.0.0",
    22.     "com.unity.modules.audio": "1.0.0",
    23.     "com.unity.modules.cloth": "1.0.0",
    24.     "com.unity.modules.director": "1.0.0",
    25.     "com.unity.modules.imageconversion": "1.0.0",
    26.     "com.unity.modules.imgui": "1.0.0",
    27.     "com.unity.modules.jsonserialize": "1.0.0",
    28.     "com.unity.modules.particlesystem": "1.0.0",
    29.     "com.unity.modules.physics": "1.0.0",
    30.     "com.unity.modules.physics2d": "1.0.0",
    31.     "com.unity.modules.screencapture": "1.0.0",
    32.     "com.unity.modules.terrain": "1.0.0",
    33.     "com.unity.modules.terrainphysics": "1.0.0",
    34.     "com.unity.modules.tilemap": "1.0.0",
    35.     "com.unity.modules.uielements": "1.0.0",
    36.     "com.unity.modules.umbra": "1.0.0",
    37.     "com.unity.modules.unityanalytics": "1.0.0",
    38.     "com.unity.modules.unitywebrequest": "1.0.0",
    39.     "com.unity.modules.unitywebrequestassetbundle": "1.0.0",
    40.     "com.unity.modules.unitywebrequestaudio": "1.0.0",
    41.     "com.unity.modules.unitywebrequesttexture": "1.0.0",
    42.     "com.unity.modules.unitywebrequestwww": "1.0.0",
    43.     "com.unity.modules.vehicles": "1.0.0",
    44.     "com.unity.modules.video": "1.0.0",
    45.     "com.unity.modules.vr": "1.0.0",
    46.     "com.unity.modules.wind": "1.0.0",
    47.     "com.unity.modules.xr": "1.0.0"
    48.   }
    49. }
    50.  
     
  13. antoine-unity

    antoine-unity

    Unity Technologies

    Joined:
    Sep 10, 2015
    Posts:
    475
    I am not getting this on my end, can you post the Editor.log files showing all compilation errors?
    I'd like to know as well what your Player Settings look like for the "Active Input Handling" setting.

    Regarding 2020.2.0b2, you should be able to install it through this link: https://unity3d.com/unity/beta/2020.2.0b2
     
  14. FizzFab

    FizzFab

    Joined:
    Feb 19, 2018
    Posts:
    12
    I am experiencing the same issue using 2020.0.0b2 after enabling the new Input System and doing the necessary restart of the editor. I am using UITK preview 9 with a new URP template project

    Here is the error message from the editor log

    I was able to fix the issue by installing the UI Builder package before enabling the new Input System. The problem does not reoccur after uninstalling the ui builder (for now).
     
  15. FizzFab

    FizzFab

    Joined:
    Feb 19, 2018
    Posts:
    12
    I am experiencing an issue with the Input System when capturing the mouse.
    I set up a little example below to illustrate the problem:

    I set up two visual elements, one of which can be dragged around with the mouse and another that logs a message on mouse enter.

    Here is the code:
    Code (CSharp):
    1. public class UiTest : MonoBehaviour
    2. {
    3.     public UIDocument doc;
    4.     private Vector2 dragStartPos;
    5.  
    6.     private void Start()
    7.     {
    8.         var root = doc.rootVisualElement;
    9.         var drag = root.Q("drag-me");
    10.  
    11.         drag.RegisterCallback<MouseDownEvent>(e =>
    12.         {
    13.             e.target.CaptureMouse();
    14.             dragStartPos = e.localMousePosition;
    15.         });
    16.  
    17.         drag.RegisterCallback<MouseMoveEvent>(e =>
    18.         {
    19.             if (!e.target.HasMouseCapture())
    20.                 return;
    21.  
    22.             Vector2 delta = e.localMousePosition - dragStartPos;
    23.             drag.style.left = drag.layout.x + delta.x;
    24.             drag.style.top = drag.layout.y + delta.y;        
    25.         });
    26.  
    27.         drag.RegisterCallback<MouseUpEvent>(e =>
    28.         {
    29.             e.target.ReleaseMouse();
    30.         });
    31.  
    32.         var area = root.Q("area");
    33.         area.RegisterCallback<MouseEnterEvent>(e => Debug.Log("Enter Area"));
    34.     }
    35. }
    This is the behavior I get using the old Input Manager. The MouseEnterEvent on the area is only called once on enter, as expected.
    Drag_OldInputManager.gif

    Using the new Input system I get this behavior. The MouseEnterEvent seems to be triggered with every MouseMoveEvent instead.
    Drag_InputSystem.gif
     
    Foge and DrSeltsam like this.
  16. caladluin

    caladluin

    Joined:
    Jan 29, 2014
    Posts:
    24
    I've been running into an issue where mouse/pointer button events aren't working. Mouse enter/leave is working fine.
    I managed to use the debugger to find that the clicks are being caught, and reach the SendEvent function in InputSystemEventSystem.cs (line 454) - but the debugger freezes for me whenever I try to debug further into that, so I don't know why it fails.
    No error is presented, and I get that error even on the root element of the visual tree.
     
  17. Djayp

    Djayp

    Joined:
    Feb 16, 2015
    Posts:
    108
    Hello ! I don't know if MouseEnterWindowEvent and MouseLeaveWindowEvent are supposed to work at runtime (they are in the UnityEngine namespace), but I wasn't able to do so using the new Input System.

    Unity 2020.2.0b2
    com.unity.inputsystem: 1.1.0-preview.1
    com.unity.ui: 1.0.0-preview.9
     
  18. antoine-unity

    antoine-unity

    Unity Technologies

    Joined:
    Sep 10, 2015
    Posts:
    475
    Hello, these events will not be sent for player panels. There are really only meant for the Editor right now, though we may support them in the future for the player.
     
    Djayp likes this.
  19. antoine-unity

    antoine-unity

    Unity Technologies

    Joined:
    Sep 10, 2015
    Posts:
    475
    Can you guys report bugs please? It is much easier for us to follow up on them this way! Thanks
     
  20. FizzFab

    FizzFab

    Joined:
    Feb 19, 2018
    Posts:
    12
    Sure! Reported Case 1284910
     
    Last edited: Oct 22, 2020
    DrSeltsam likes this.
  21. DrSeltsam

    DrSeltsam

    Joined:
    Jul 24, 2019
    Posts:
    76
    The new input system integration works quite well for me so far :) One thing that's a bit strange (and maybe a bug I guess) is the scroll behaviour if "Time.timeScale" is != 1: The "InputSystemEventSystem.cs" (in ../GameObjects/InputSystem) uses Time.deltaTime instead of Time.unscaledDeltaTime in OnScrollWheelPerformed() - which affects the scroll speed (or prevents scrolling from working at all if Time.timeScale is set to 0)
     
  22. DrSeltsam

    DrSeltsam

    Joined:
    Jul 24, 2019
    Posts:
    76
    I can now confirm the issue mentioned by @Fizz94 ... I didn't realize it in previous versions, but since preview.12, updating UI elements apparently became a lot more expensive (I was updating an element when MouseEnter was triggered, and it worked fine in previous versions [even though MouseEnter got called every frame], but now I get a huge frame drop due to the frequent updates).

    Unfortunately it also looks like the scroll behaviour still depends on Time.deltaTime instead of Time.unscaledDeltaTime in preview.12. I pause my game by setting Time.timeScale to 0, but then I cannot scroll any lists in the pause menu via mouse wheel anymore (while the rest of the UI still works fine) :(
     
  23. johaga

    johaga

    Joined:
    Oct 10, 2019
    Posts:
    6
    I'm not sure where this goes - I also posted this Using new Input System with UI Toolkit - Unity Forum but I'm trying to figure out how, when using UI Toolkit and the new Input System together, how I am supposed to figure out if someone has clicked the UI or the ground behind it.

    I can't just throw up a giant blank window because that won't stop the Input System's clicks. It also appears that I can't use a Physics.Raycast to determine if the mouse cursor is over the UI. (The Raycast never returns a hit for the UI elements.)

    Is there a way to get the UI System to consume clicks so that the Input System doesn't trigger the other action maps?
     
  24. uBenoitA

    uBenoitA

    Unity Technologies

    Joined:
    Apr 15, 2020
    Posts:
    104
    Hi Johaga, DrSeltsam,

    Concerning the Time.deltaTime issue, it has been duly noted and a fix is slowly getting its way into a public version to come, though I can't say exactly when. The fact is that the new Input System support for UI Toolkit is a bit more complicated to develop than the rest of the features due to some features being dependent on changes from the two packages at once.

    This added complexity also affects our development for non-UI Raycast support, which we started to add to UI Toolkit a few months ago and which is still not fully supported with the new Input System unfortunately. We do have plans to make it possible to treat UI Toolkit panels like valid UGUI objects through the use of a few components, blocking Raycast and sharing UGUI events through the StandaloneInputSystem or its new Input System replacement. However that is not yet publicly available and might not be for some time.

    In the meantime, there is something you can do if you really need it to work.

    Code (CSharp):
    1. using System.Collections.Generic;
    2. using UnityEngine;
    3. using UnityEngine.EventSystems;
    4. using UnityEngine.UIElements;
    5.  
    6. public class MyUIToolkitRaycaster : BaseRaycaster
    7. {
    8.     public IPanel panel; // TODO: Set me at start up
    9.  
    10.     public override Camera eventCamera => null;
    11.  
    12.     public override void Raycast(PointerEventData eventData, List<RaycastResult> resultAppendList)
    13.     {
    14.         var p = eventData.position;
    15.         p.y = Screen.height - p.y;
    16.         var panelPosition = RuntimePanelUtils.ScreenToPanel(panel, p);
    17.  
    18.         var pick = panel.Pick(panelPosition);
    19.         if (pick == null)
    20.             return;
    21.  
    22.         resultAppendList.Add(new RaycastResult
    23.         {
    24.             gameObject = this.gameObject,
    25.             module = this,
    26.             screenPosition = eventPosition
    27.         });
    28.     }
    29. }
    30.  
    By extending BaseRaycaster and putting that component on a GameObject in your scene, it will be subscribed to UGUI's event system (you would need to set up UGUI's event system too), and it will allow you to use methods such as
    EventSystem.IsPointerOverGameObject
    , and to block clicks that would otherwise fall through.

    I hope this helps :)
     
  25. DrSeltsam

    DrSeltsam

    Joined:
    Jul 24, 2019
    Posts:
    76
    Thanks for your response @uBenoitA :)

    The Time.deltaTime issue, however, seemingly just requires a single line to be changed, as mentioned above: In
    ../GameObjects/InputSystem/InputSystemEventSystem.cs
    it's line 239 where
    scrollDelta *= Time.deltaTime;
    just needs to be replaced with
    scrollDelta *= Time.unscaledDeltaTime;
    .

    I've copied the UI Toolkit package (preview.13) and changed that line locally and this indeed fixes the scroll issue. I'd still prefer to see a fix for this in the actual UIToolkit package though ;)
     
  26. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    5,577
    There's some clunkyness, but it might be me doing something weird.

    I'm trying to make an on-screen controller. This is supported out of the box in the Input System with some components (On-Screen Button etc.) that uses uGUI components.

    I tried to do something similar, and I'm running into a weird corner-case. I'm creating a virtual gamepad, and turning button clicks into clicks on that gamepad. But;
    - If the PlayerInput component is set to use a gamepad-based control scheme, mouse clicks are ignored by the EventSystem
    - If the PlayerInput component is set to use a mouse/keyboard-based control scheme, the virtual inputs are ignored by things listening to the PlayerInput.
    - If I use the default input scheme that's generated that has support for both, and select "any", it seems like clicking on the screen puts it into mouse-mode, which again makes the inputs ignored.

    I'm not quite sure how to go about this. In the old input/UI systems, you always got mouse inputs even if they weren't "bound" to anything, since there was no such thing as a binding in the system.

    I think it's good that we can rebind things like "what is the thing that moves the mouse/what is a selection click" in order to support emulating mouse with a gamepad or for supporting accessibility devices, but it seems a bit cumbersome that we have to tell the system that "hey, this is what a left click is", and needing an active binding to have it works seems clunky in some way.

    I might be missing something, though! Or this might be an input system issue.
     
  27. johaga

    johaga

    Joined:
    Oct 10, 2019
    Posts:
    6
    So I was asking a similar question over on the UITK side, and it turns out that it's possible to adapt the "invisible layer" approach, but instead with UITK instead of UGUI.
    Code (CSharp):
    1.  
    2. public class UIDetector : MonoBehaviour
    3. {
    4.     public UIDocument rootDocument;
    5.     public static bool OverUI;
    6.     // Start is called before the first frame update
    7.     void Start()
    8.     {
    9.         var visualElement = rootDocument.rootVisualElement.Q<VisualElement>("rootVisual");
    10.         visualElement.RegisterCallback<MouseOverEvent>((evt) =>
    11.         {
    12.             OverUI = evt.target != visualElement;
    13.         });
    14.     }
    15. }
    16.  
    And "rootVisual" in this case is just a giant empty visual element that covers the whole screen.

    So basically I just check in every Input Event if "OverUI == true" then bail on the event. Not pretty by any stretch, but allows me to keep the code in a controller, and not have to modify the in-scene GameObjects.
     
  28. JayStGelais

    JayStGelais

    Joined:
    Apr 8, 2019
    Posts:
    1
    Is there a sample project that has this working that I can pull down from somewhere. I must be missing something, but nothing I do makes it so that my UI components ever actually receive move, submit or cancel events.

    Edit:
    An hour after asking this question I figured it out. I'll leave this here incase anyone else has the same issue I had. The problem I had was that the VisualElement I was registering the event handlers with was not focusable, so nothing happened when I called Focus(). Setting focusable to true in Awake() fixes this.

    This was for a popup message window that the player can dismiss with either the submit or cancel buttons. Just a styled VisualElement with a TextElement in it.
     
    Last edited: Jan 31, 2021
  29. Wolftousen

    Wolftousen

    Joined:
    Nov 25, 2016
    Posts:
    10
    Went to try this out with the Player Input Manager and split screen mode and doesn't look like it's working.

    Each player has their own camera and clear color so i could see they were getting split properly, but the UI Document on each player was not being scaled/positioned to their camera. Everyone just had a full screen UI and could only see the UI for player one unless i disabled player one.

    Is support for the split screen mode going to be added in the future?
     
  30. Timboc

    Timboc

    Joined:
    Jun 22, 2015
    Posts:
    191
    This feature has been a bit of a life-saver for us so we're glad you put it out. One thing that would be great for you to be thinking about (if the team's not already) is how this interacts with XR. We are currently successfully invoking the new input system actions for when an xr controller moves/points/clicks. The main hack however is that we have to raycast into scene, then convert to Vector2 (screen pos) in order to map to the 'point' override - where upon we override the ScreenToPanelSpaceFunction as per the render texture example and raycast out again.
    Hacks aside this is largely working which is awesome.
     
  31. antoine-unity

    antoine-unity

    Unity Technologies

    Joined:
    Sep 10, 2015
    Posts:
    475
    In the future what you are describing should be possible by arranging a few things in your scene, like having two PanelSettings objects, to separate the rendering into two cameras. However UI Toolkit does not yet support rendering into cameras, only "overlays" which is rendered on top of any camera. A work around for now will be to manually assign areas of the the screen to the two UI Documents.
    Local multiplayer input in one UI is also not support yet, though it doesn't look like what your use case.

    Would you mind starting a different forum thread for this? We would like to understand your use case a bit more. I am also quite curious to see how you got the input to work in this case. Thanks
     
  32. marcospgp

    marcospgp

    Joined:
    Jun 11, 2018
    Posts:
    66
    I just updated Unity from 2020.2.1f1 to 2020.3.1f1 and started getting the following error:

    Changing
    Active Input Handling
    under
    Project Settings > Player
    from
    Input System Package (New)
    to
    Both
    fixes the issue, but I'd rather not have both input systems enabled.

    How can I fix this issue? Thanks!
     
  33. christianstamati

    christianstamati

    Joined:
    Jul 13, 2018
    Posts:
    14
    Hi,
    I'm using Unity 2021.2.0a10 and UI Toolkit is available by default. I created a simple button and registered a callback to display a simple debug message. On pc with the old and new input system works. When I try to build for android with the old input system works but with the new one I receive an error: (also when I simulate touch in editor on the input sys)

    Code (CSharp):
    1. IndexOutOfRangeException: Index was outside the bounds of the array.
    2. UnityEngine.UIElements.PanelEventHandler+PointerEvent.Read (UnityEngine.UIElements.PanelEventHandler self, UnityEngine.EventSystems.PointerEventData eventData, System.Boolean isMove) (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/UIElements/PanelEventHandler.cs:377)
    3. UnityEngine.UIElements.PanelEventHandler.ReadPointerData (UnityEngine.UIElements.PanelEventHandler+PointerEvent pe, UnityEngine.EventSystems.PointerEventData eventData, System.Boolean isMove) (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/UIElements/PanelEventHandler.cs:321)
    4. UnityEngine.UIElements.PanelEventHandler.OnPointerDown (UnityEngine.EventSystems.PointerEventData eventData) (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/UIElements/PanelEventHandler.cs:134)
    5. UnityEngine.EventSystems.ExecuteEvents.Execute (UnityEngine.EventSystems.IPointerDownHandler handler, UnityEngine.EventSystems.BaseEventData eventData) (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/ExecuteEvents.cs:43)
    6. UnityEngine.EventSystems.ExecuteEvents.Execute[T] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.ExecuteEvents+EventFunction`1[T1] functor) (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/ExecuteEvents.cs:272)
    7. UnityEngine.EventSystems.EventSystem:Update() (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/EventSystem.cs:501)
    Her's the video:


    Could you help me with this? I'm new to ui toolkit maybe I missed some setting...
     
  34. Endlesser

    Endlesser

    Joined:
    Nov 11, 2015
    Posts:
    44
    As far as I know, This bug case is caused by `Mouse is constantly moving out of whole UI by certain behaviors`

    Certain behaviors like:
    1.Add new VisualElements to a root VisualElement.
    2.Set label's text to a new value. (not if you manual setting the label's size in UI Builder)
    3.Moving by set style's left`right`top`bottom.
    ..

    I reckon there's something make the entire UI Updated once and my mouse always goes to a position located at (235.0f, 40.0f) with some deviation(bizarre as it sounds).

    Did I solve this bug yet? not really... maybe there is a trick to override it and have to go deeper. Since I can't wait a long time like 5 months to get a fix.

    Try put some log pic next time~

    --------Edit----------
    Little progress here, the weird position that mouse is constantly go to is a result calc by different windows, the green marks the actual pos and its according window, and that's correct, the red marks the false pos and its according window, so if you put a VisualElement at pos(0f,0f), then it goes to a pos like(0f + width gap between 2 windows, 0f + height gap between 2 windows) whenever certain behavior triggers. Altering the scale of game window will always change the false outcome pos.

    mouse out.png
    mouse out 2.png

    Hopefully this can give a hint to fix it.

    Still working on a trick to bypass it, by comparing the last mouse correct pos and the flying- random pos,I know when it happens. The question is, how am I going to send the last correct pos to UItoolkit to override the false pos?

    ----------2nd Edit------------
    Issues still after updated to 2020.3.6f, with input package 1.1.0 preview.3
    But there're some rules to keep it undetectable like:
    1.Make changes to `Display` `size` `position` at runtime will cause MouseOutEvent triggered.
    2.Make changes to `Opacity` `Color` at runtime is safe.
    3.Make changes to `text` depends on if text element size is auto or fixed.

    So, if you are setting a label's text every frame, and it's auto size, the issue will reappear every frame.
    If you are using experimental animation to animate position change, the issue will reappear for every time of its new pos.

    Well this is going rare and more weird now...
     
    Last edited: May 7, 2021
  35. jtiret

    jtiret

    Joined:
    Nov 11, 2020
    Posts:
    51
    I have an issue on iOS when I tell UI Toolkit to use the new input system: the scroll on ScrollView (and ListView) doesn't work anymore (but it does work with the old input system). I have created a topic about this issue (before I realising that there was a pinned topic about the support of new input system within UI Toolkit). Here is the topic: https://forum.unity.com/threads/scrolling-not-working-on-ios-with-new-input-system.1086386/

    Did someone have the same issue?
     
  36. schwmm

    schwmm

    Joined:
    Oct 20, 2020
    Posts:
    35
    Hi,
    in my game I regularly switch between different scene types with different control scemes (UI, 3D, Cutscenes, etc.). For this I have a static InputManager class, where I enable and disable the relevant actionmaps of the ActionAsset instance there.
    This is not possible with the referencing in your Input Module. Is there any workaround?
    Basically I want to be able to disable all controls by disabling the UI ActionMap of my InputAsset.
     
  37. moatdd

    moatdd

    Joined:
    Jan 13, 2013
    Posts:
    54
    The ListView scrolling needs to auto-calibrate.

    When I scroll the mousewheel, it goes up and down by just a few pixels.
    Instead, each 'tic' of the mousewheel should scroll the listview by one full entry.

    Also the page up/page down behaviour of the listview should go by (you guessed it) ONE FULL PAGE.
    On the scroll bars, there is the gaps above and below the middle grab-handle. Clicking those should also scroll by one full page.

    Lastly, ListView must receive NavigationSubmitEvents when focused. It doesn't. Can't make gamepads work with the Listview like this.

    Listview's gotta be able to respond to artificial scroll events generated by my gamepad's right-stick. (since left stick is used for Navigation Movement). Can't seem to be able to make this happen without significant effort on my end.
     
  38. wanfei

    wanfei

    Joined:
    Dec 22, 2018
    Posts:
    14
    @uBenoitA Hi, In InputSystem,the keyboard not trigger InputField from InputSystem.QueueStateEvent.How to Solve it?
    Thank you very much.
     
  39. uBenoitA

    uBenoitA

    Unity Technologies

    Joined:
    Apr 15, 2020
    Posts:
    104
    You need to have either the InputSystemEventSystem component added somewhere in your scene, or the [EventSystem + InputSystemUIInputModule] from UGUI, which will make UITK stop trying to use the legacy input.
     
    LYN1995 likes this.
  40. uBenoitA

    uBenoitA

    Unity Technologies

    Joined:
    Apr 15, 2020
    Posts:
    104
    Unfortunately you're not missing anything. Actually, the Input System package is missing a fix for UI Toolkit compatibility. They are very, very, very slow to integrate our fixes to their package.... but it's there and it should be out in the very near future, I'm told. I'm really sorry for your inconvenience. If you're totally blocked by this, there _is_ a workaround, but I think you would be better just waiting for the Input System package update.
     
    christianstamati likes this.
  41. uBenoitA

    uBenoitA

    Unity Technologies

    Joined:
    Apr 15, 2020
    Posts:
    104
    Our most recent theory on how to fix case 1284910 is that it's caused by runtime panels and editor window panels fighting to set their cached mouse positions on the same screen positions, and erasing each other's data. That cached data is processed when an element changes size or position, among other things. The element under pointer calculations is erroneous and it causes undesired Pointer Enter/Leave events. It shouldn't be moving the mouse cursor though. I think what you have is a new thing of its own, one that I haven't seen on my end yet, or so it seems. Thank you for your thorough investigation on specific repro situations. Could you maybe open a bug report for it, with a simple project setup that reproduces it?

    As for case 1284910, we're not entirely done fixing the issue but there is a fix in the works, so maybe it'll fix yours at the same time...
     
    Endlesser and FizzFab like this.
  42. uBenoitA

    uBenoitA

    Unity Technologies

    Joined:
    Apr 15, 2020
    Posts:
    104
    I asked someone on the team to look into reproducing it, thank you. We might ask you to submit a bug for us, but let's first see if some of our recent changes might have fixed it by any chance :)

    EDIT: yep, it's been fixed and should be out in the next public package update. Unfortunately I can't say exactly when that's going to happen, but it'll be in the short term.

    https://issuetracker.unity3d.com/is...l-doesnt-work-when-using-the-new-input-system
     
  43. uBenoitA

    uBenoitA

    Unity Technologies

    Joined:
    Apr 15, 2020
    Posts:
    104
    You're right, we don't support a seamless hot-swapping of the actions, but indeed I believe you can work around it with the following:
    - Disable the InputSystemEventSystem component
    - Change you action map
    - Enable the InputSystemEventSystem component

    If it doesn't work, then I should really consider implementing it properly in a future patch. However, this will be a relatively low priority feature so it might take some time. I think the workaround should work though.
     
  44. uBenoitA

    uBenoitA

    Unity Technologies

    Joined:
    Apr 15, 2020
    Posts:
    104
    Thank you for your feedback! I've forwarded your recommendations to the right people, with some luck it should make its way into a list of things to improve in future quality of life fixes. Some of those changes are definitely more than quality of life though, like NavigationSubmit for ListView. I agree it's something that should be added as soon as reasonably feasible.
     
  45. uBenoitA

    uBenoitA

    Unity Technologies

    Joined:
    Apr 15, 2020
    Posts:
    104
    Hi Wanfei,

    If you are using the InputSystemEventSystem component, then the event that it listens to is the TextEvent, from the UnityEngine.InputSystem.InputSystem.onEvent callback. You can see InputSystemKeyboardEventProcessor.cs to have a look at how we are handling the keyboard events. I'm not an expert of the Input System package unit testing features, but there's probably a way to queue TextEvents specifically, and in that case it should be working.

    If you are using the [EventSystem + InputSystemUIInputModule] combination, then keyboard events are handled separately than the rest at the moment and rely on older event types, which might not support manual queueing for testing purposes. In that case you could probably ask for some help on the Input System package forum: https://forum.unity.com/forums/input-system.103/

    Best of luck
     
  46. christianstamati

    christianstamati

    Joined:
    Jul 13, 2018
    Posts:
    14
    Thanks for the update! ;)
     
  47. schwmm

    schwmm

    Joined:
    Oct 20, 2020
    Posts:
    35
    Thanks for your reply. Maybe I expressed myself wrong - I have a separate, existing instance of the InputAsset which I would like to query instead of creating a new one when enabling the Input System UI Input Module.

    I described it in here: https://forum.unity.com/threads/poi...nput-manager-script-new-input-system.1098634/

    Is this something that will be possible in future? As it stands I cannot really access some features of the new input system with the UI module.
     
unityunity