Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

New input system - webgl and touch

Discussion in 'Input System' started by MythicalCity, Jun 13, 2020.

  1. MythicalCity

    MythicalCity

    Joined:
    Feb 10, 2011
    Posts:
    414
    Hi, I am trying the new input system and it works great on webgl for mouse/keyboard but touch doesn't work on webgl. With the old input system touch is automatically working in UI and things like getaxis horizontal, but with new one even the UI doesn't respond to touch input (obviously this is on mobile devices that have touch in the browser).

    Is there something special that needs to be added to accept touch for webgl?

    I have the default UI actions setup:
    https://share.getcloudapp.com/P8ueReyX
    https://share.getcloudapp.com/qGuKoKl4
     
    davtam likes this.
  2. MythicalCity

    MythicalCity

    Joined:
    Feb 10, 2011
    Posts:
    414
    Bump, any suggestions? Is this a bug with the input system or does it just not support WebGL touch?
     
  3. Rene-Damm

    Rene-Damm

    Unity Technologies

    Joined:
    Sep 15, 2012
    Posts:
    1,779
    Hi @MythicalCity, sorry to leave you hanging.

    Did you replace StandaloneInputModule with InputSystemUIInputModule? Is the UI working with the mouse?

    Touch on WebGL is expected to work at least to the same extent it does in the old input system.
     
  4. MythicalCity

    MythicalCity

    Joined:
    Feb 10, 2011
    Posts:
    414
    Thanks for the reply. Yes, as per my screenshot above, https://share.getcloudapp.com/qGuKoKl4 I have that module and the UI works great with a mouse, just no reaction for UI or anything else with touch.
     
  5. Rene-Damm

    Rene-Damm

    Unity Technologies

    Joined:
    Sep 15, 2012
    Posts:
    1,779
    Would you mind filing a ticket with the Unity bug reporter? ("Help >> Report a Bug..." in the editor's main menu) This should get looked at on our side.
     
  6. MythicalCity

    MythicalCity

    Joined:
    Feb 10, 2011
    Posts:
    414
    OK I have made a reproduction project and submitted it here is the bug number 1257101
     
    Rene-Damm likes this.
  7. MythicalCity

    MythicalCity

    Joined:
    Feb 10, 2011
    Posts:
    414
    BTW, just an update, if I add the code: Input.GetTouch(0).deltaPosition then the touch control works, but I guess that is using the old input system and new one at the same time.
     
    Last edited: Jun 22, 2020
  8. MythicalCity

    MythicalCity

    Joined:
    Feb 10, 2011
    Posts:
    414
    @Rene-Damm any luck looking into this issue? I have a project deadline coming up that needs to add touch support so it would be great to know if this is just a user error on my end or an issue with the input system.
     
  9. MikeBru

    MikeBru

    Joined:
    Mar 28, 2016
    Posts:
    2
    running into a similar issue with webgl and touchscreen support. seems like an input system issue. Curious if there is a solution though.
     
  10. MythicalCity

    MythicalCity

    Joined:
    Feb 10, 2011
    Posts:
    414
    I haven't heard back yet from Unity about this or the bug report I made (which is pretty typical, I've never heard back about bug reports I've filed so not sure whether we should expect a reply) probably best to just find a workaround. For now I implemented the touch with duplicate code that uses the old input system Input.Touches... which works fine in combination with the new system, it just means you'll have twice the code to do the same thing.
     
    MikeBru likes this.
  11. MythicalCity

    MythicalCity

    Joined:
    Feb 10, 2011
    Posts:
    414
    @MikeBru just actually heard back from someone at unity, they said they won't fix the issue until mobile is officially supported for webgl.
     
  12. MikeBru

    MikeBru

    Joined:
    Mar 28, 2016
    Posts:
    2
    @MythicalCity thanks for passing on that update. I suppose it will be awhile before we see that feature then. You don't happen to know when Unity is planning to bring Webgl support to mobile per-chance?
     
  13. MythicalCity

    MythicalCity

    Joined:
    Feb 10, 2011
    Posts:
    414
    No sorry, I have no idea.
     
  14. Rene-Damm

    Rene-Damm

    Unity Technologies

    Joined:
    Sep 15, 2012
    Posts:
    1,779
    AFAIK there's no near-term plans WRT mobile support for WebGL. However, touch support for WebGL in the new input system backends is already implemented and shipped so from all I know at this point, this looks like it's simply a bug. Looking into the status of the ticket.
     
  15. iholodeck

    iholodeck

    Joined:
    Oct 26, 2019
    Posts:
    2
    Same problem
     
  16. MintFox

    MintFox

    Joined:
    Jan 15, 2017
    Posts:
    1
    this bug is very dissapointing. I was excited to get mobile working on my game, but it appears I can't so much as pass the main menu. I suppose if I want to consider mobile on my webgl games I'll just have to use the old input system.
     
  17. bobbaluba

    bobbaluba

    Joined:
    Feb 27, 2013
    Posts:
    81
    Hi @Rene-Damm, this is still happening on the latest LTS (2019.4.18) and input system 1.0.2.

    Some potentially interesting findings, however:

    - On Unity 2019.4.18 it doesn't work with either input system 1.0.2 or 1.1.0-preview2
    - On Unity 2020.1.7 it works with both input system 1.0.2 and 1.1.0-preview2
    - On Unity 2020.2.2 (latest stable) it works with the stable input system version (didn't test the preview, but would assume it works)

    I made a minimal test project and submitted it through the reporting tool, but here it is as well (on 2019.4.18 LTS and stable input system version) in case someone else stumbles upon this thread later and wants to see if it's been fixed in a later LTS version.

    https://github.com/johanhelsing/unity-touch-bug

    To reproduce, switch to WebGL, click build and run, open dev tools and enable touch/device mode. Try clicking either of the buttons (they should switch color, but they don't).

    upload_2021-1-31_13-0-32.png

    TL;DR: Looks like you need to ditch the 2019 LTS if you want touch support (at least for now).

    Otherwise, the new input system is looking great, and 2020 LTS will hopefully release soon... looking forward to finally switch :)
     
  18. Dattoffer2

    Dattoffer2

    Joined:
    Oct 29, 2018
    Posts:
    2
    Hi, do you know what's the state of Touch Input for WebGL on Unity2018 ? I'm working on that version and I can't seem to get the Touch Inputs to work. (Although it could come from my device, so I'd rather ask)
     
  19. Wasp3r

    Wasp3r

    Joined:
    Dec 6, 2020
    Posts:
    7
    Any news on this topic? I've found out, that touch is working for in our case, but it's kinda off. It's not fixed offset thou, it's changing as you move from the left upper corner.
    You can see it on the gif attached. The angry emoji icon is moved on the pointer position. Has anyone know what it might be? Everything is working fine on iOS, Android, and Windows. It's also working in WebGL when you operate with the mouse.
    We are using Unity 2020.3.22f1

    SOLUTION: ok I know what it was. Unity canvas has the wrong scale on mobile. That was because mobile devices have different pixel ratio than desktop browsers. We simply had to multiply canvas size by window.devicePixelRatio :)

    Cursor.gif
     
    Last edited: Jan 21, 2022
  20. JulesVerny

    JulesVerny

    Joined:
    Dec 21, 2015
    Posts:
    39
    Wow so Unity really not supporting Touch input on basic WebGL games !
    That has just wrecked my ambitions.