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.
  2. Dismiss Notice

Single touches don't seem to work on WebGL/iOS, but drags do

Discussion in 'WebGL' started by Kadakadak, Jul 6, 2022.

  1. Kadakadak

    Kadakadak

    Joined:
    Apr 27, 2020
    Posts:
    4
    I have a simple cube with a box collider and a script with OnMouseUp/OnMouseDown which just toggles the box's color. It works fine on the desktop.

    However, if I make a WebGL build and try it on iOS (in Safari or Chrome) I only see events if I drag my finger. A simple tap (down and up) doesn't register at all.

    Is there something else I should be doing in this situation?
     
  2. Kadakadak

    Kadakadak

    Joined:
    Apr 27, 2020
    Posts:
    4
    FWIW, I can see single touch begins and ends with Input.GetTouch(0). I guess I'll plumb them through myself.
     
  3. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    8,991
    at least on ipad iOS, had to disable Desktop browsing mode from (Settings/Safari/Desktop Browsing),
    that helped for me (when touches were not registered normally).
     
  4. Kadakadak

    Kadakadak

    Joined:
    Apr 27, 2020
    Posts:
    4
    Ah. Interesting idea! I gave that a go, but it didn't get the traditional OnMouseUp handlers working. Browser touch/mouse/pointer events are something of an undisciplined mess to begin with, so I guess I'm not surprised Unity is having trouble with it.
     
  5. C0lonnello

    C0lonnello

    Joined:
    Nov 7, 2022
    Posts:
    24
    Hi, I'm having the same issue in my webGL build running on mobile browser. I have built objects with drag n drop functionality using mouse drag and new input system.
    Trying this application on mobile browser, if I just tap the object i don't receive the mouse press cancel event; If I drag the finger I receive immediately the mouse press cancel event, and so I cannot interpret is as dragging.

    Are there any ways to work with touch events in new input system for webGL running on mobile?
     
  6. GDevTeam

    GDevTeam

    Joined:
    Feb 14, 2014
    Posts:
    90
    I'm slowly working my way through this paid solution.
    https://assetstore.unity.com/packages/tools/input-management/fingers-touch-gestures-for-unity-41076

    I'm looking forward to innate Unity complete mobile support for WebGL on this front.
     
  7. unityruba

    unityruba

    Unity Technologies

    Joined:
    Nov 6, 2020
    Posts:
    233
    Hi everyone,

    A few of questions:
    1. Is this only on the new input system?
    2. Which version is this happening in?
    2. Is there a bug report I can take a look at? *smiling tearful face*
     
  8. unityruba

    unityruba

    Unity Technologies

    Joined:
    Nov 6, 2020
    Posts:
    233
    I definitely recall fixing touch event bugs on mobile devices so if this is a new issue then it's a regression.
     
  9. C0lonnello

    C0lonnello

    Joined:
    Nov 7, 2022
    Posts:
    24
    Hi, I have an update regarding this. Working with Press input of new input system with Touch as binding now the drag works as intended. The only issue that I'm having is that sometimes it still doesn't register the "Mouse Up" event if I don't move the mouse after I pressed it.

    To recap briefly:
    - the sequence Press - Move - Release is all handled correctly
    - the sequence Press - Release is not handled correctly since the Release event isn't received

    New Input System
    Unity 2022.2.xx
     
    GDevTeam likes this.