Search Unity

Resolved XR Interaction Toolkit no Scroll Handling implementation?

Discussion in 'XR Interaction Toolkit and Input' started by MaskedMouse, Sep 15, 2020.

  1. MaskedMouse

    MaskedMouse

    Joined:
    Jul 8, 2014
    Posts:
    1,092
    I noticed that when interacting with UI using the XR Interaction Toolkit that it doesn't seem to have any mechanism for Scrolling through content using the primary 2D Axis.
    I can create a workaround that gets the feature value every frame and send it to the scroll handler manually. But it would be nice if this were implemented in the input module as event driven change.
    The mouse scroll is negating the scroll every frame as well. This causes the scroll rect to not scroll at all.

    I tracked down the issue with the mouse scroll events not working when using Mouse input.
    The MouseModel has 2 properties, scrollPosition and scrollDelta.
    The scrollPosition is being set to the Input.MouseScrollDelta
    The ScrollHandler uses the scrollDelta property which is set by the scrollPosition property
    scrollDelta = value - m_ScrollPosition;
    .
    if frame 0 the scrollPosition is (0, -1) then the next frame (0, 0) the scrollDelta will be 1. Negating the scroll in the ScrollHandler that has been performed previous frame.

    I added the XR Scrolling myself and fixed the mouse scrolling while I was at it.
    for XR Scrolling I added to the UIInputModule

    Code (CSharp):
    1.                 // Get XR Device
    2.                 var rightHand = InputDevices.GetDeviceAtXRNode(XRNode.RightHand);
    3.                 if (rightHand.isValid && rightHand.TryGetFeatureValue(CommonUsages.primary2DAxis, out var scrollDelta))
    4.                     eventData.scrollDelta = scrollDelta;
    5.                 else
    6.                     eventData.scrollDelta = Vector2.zero;
    and calling
    ProcessMouseScroll(eventData);


    For fixing the MouseScroll I changed the
    CopyTo
    method of the
    MouseModel

    changed eventData.scrollDelta = scrollDelta;
    to
    eventData.scrollDelta = scrollPosition;


    Bit of a hacky workaround but yeah it does the trick.


    TLDR for Mouse Scrolling Issue.
    In the original StandaloneInputModule the ScrollDelta is set directly with Input.MouseScrollDelta
    in the MouseModel used by the XRUIInputModule it calculates the delta based on a previous frame. Which causes this issue.
    Filed a bug report case 1278162

    TLDR for XR scrolling
    Scrolling using a controller left or right stick isn't even implemented. Only for the mouse and even that is bugged.
     
    Last edited: Sep 16, 2020
    tlskillman likes this.
  2. Michael316

    Michael316

    Joined:
    Aug 2, 2012
    Posts:
    21
    Where did you add the XR Scrolling code pasted above in UIInputModule.cs? I'm stuck on this issue, too. Thanks!
     
  3. MaskedMouse

    MaskedMouse

    Joined:
    Jul 8, 2014
    Posts:
    1,092
    I updated the XR package. Don't think I have re-added it to the new update yet.
    Basically how I did it before was:
    - Get the Left / Right hand controller
    - Get the Secondary2DAxis value
    - Apply that as eventData.scrollDelta value
     
  4. Michael316

    Michael316

    Joined:
    Aug 2, 2012
    Posts:
    21
    Thank you - so I am using the newest preview package, and I understand the issue, but couldn't quite find where that code would go. Any time I try to get any sort of Mouse Input I get an error stating that the new Input system prohibits use of the old one.
     
  5. MaskedMouse

    MaskedMouse

    Joined:
    Jul 8, 2014
    Posts:
    1,092
    I haven't really used the new input system yet due to the fact that other packages relied on the old input system.
    The newest version of the XR interaction should be able to use the new input system. So you can probably set the eventData.scrollData with that. But I don't know how yet as I've only used the new input system a long time ago and only for a day.
     
  6. mfuad

    mfuad

    Unity Technologies

    Joined:
    Jun 12, 2018
    Posts:
    335
    Hi @MaskedMouse, case 1278162 has been fixed. Please upgrade to XR Interaction Toolkit 0.10.0-preview.7.

    Regarding using a controller left/right stick for UI scrolling, please check out our response in this thread. We recommend submitting a feature request in our public roadmap so we can properly track and prioritize accordingly.
     
  7. MaskedMouse

    MaskedMouse

    Joined:
    Jul 8, 2014
    Posts:
    1,092
    I've send requests to the roadmap already but I am uncertain whether they get received or not.
     
  8. mfuad

    mfuad

    Unity Technologies

    Joined:
    Jun 12, 2018
    Posts:
    335
    We received it, and have it noted in our backlog for when we plan future versions. Thanks!
     
  9. nikokoneko

    nikokoneko

    Joined:
    Feb 20, 2015
    Posts:
    35
    Any estimated time for this feature? Thanks.