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

Touch events in WebGL - Two taps

Discussion in 'WebGL' started by btschumy, Jun 1, 2021.

  1. btschumy

    btschumy

    Joined:
    Jul 31, 2019
    Posts:
    91
    I realize mobile devices are not fully supported in WebGL. However, I find that on tablets and larger phones, my UI does layout correctly and touch events sort or work. The problem is that it often takes two taps in scene for the tap to register. It is almost like the view needs to have focus before responding to the tap. When the app first starts up, I need to tap and then tap again for something to happen. After gaining "focus" I only need a single tap.

    If I then tap something in the my canvas, that generally works the first time but then tapping back in the main view will again require two taps.

    I am using the "old input system" for this where you do things like Input.GetTouch(0) and
    Input.GetMouseButton(0) in Update().

    Is there something I can do to eliminate the need for two taps? Am I doing something wrong that causes this?
     
  2. Marks4

    Marks4

    Joined:
    Feb 25, 2018
    Posts:
    491
    Try using pointerdown instead of onclick and see if that helps.
     
  3. jukka_j

    jukka_j

    Unity Technologies

    Joined:
    May 4, 2018
    Posts:
    944
    This does sound like some kind of a UI bug. If you have a small test case, please do report it as a bug. Mobile input activation should not require two taps, not even via the mouse button emulation mode.

    Also curious to hear if the pointer events avoid the issue like Marks4 suggests.
     
  4. btschumy

    btschumy

    Joined:
    Jul 31, 2019
    Posts:
    91
    It will take a substantial rewrite of my code to change to event based handling for down, drag and up user gestures. Not quite sure I'm ready to try this. I don't use onClick events for this bit of code.

    I'm somewhat new to Unity and am always a bit unsure about the old event system and the new event system (and there was apparently an even older event system). Is the use of PointerDown part of the new system or the old one?

    I will try to create a simpler example that shows this behavior. Maybe that will illuminate the problem.

    In any case it doesn't sound like this is the expected behavior when running under WebGL.
     
  5. jukka_j

    jukka_j

    Unity Technologies

    Joined:
    May 4, 2018
    Posts:
    944
  6. De-Panther

    De-Panther

    Joined:
    Dec 27, 2009
    Posts:
    552
    Is the Unity build run in a custom page? maybe something in the page is taking the focus?

    I'm using both the EventSystem and Input.touch, and I didn't notice this issue.

    Can you share a sample page?