UnityRenderStreaming icon indicating copy to clipboard operation
UnityRenderStreaming copied to clipboard

[BUG]: cannot use touch scroll on UI

Open gawinwong opened this issue 3 years ago • 3 comments

Package version

3.1.0-exp.3

Environment

* OS: Ubuntu 18.04
* Unity version: 2020.3.3
* Graphics API: Vulkan
* Browser: chrome 102.0.5005.61

Steps To Reproduce

  1. use broadcast sample
  2. add scroll view on canvas
  3. use webapp to receive render stream

Current Behavior

I can use mouse or wheel to scroll the the viewport, but cannot do that with touch slide on screen. I have found that this action will dispatch the event "touchmove", but cannot scroll the viewport. Whether it's the problem that Unity Input System doesn't support touch scroll or it's a bug of webapp?

Expected Behavior

No response

Anything else?

No response

gawinwong avatar May 31 '22 09:05 gawinwong

Alright, it's because input system cannot process touch event. We can convert touch events to mouse events to scroll on UI. Hers is my solution, apply these changes to client/public/js/sender.js. And this can only use with one finger touch on screen.

_onTouchEvent(event) {
      // this.touchscreen.queueEvent(event, this.timeSinceStartup);
      // for (let touch of this.touchscreen.currentState.touchData) {
      //   this._queueStateEvent(touch, this.touchscreen);
      // }
    var touch = event.changedTouches[0];
    var simulatedEvent = new MouseEvent({
      touchstart: "mousedown",
      touchmove: "mousemove",
      touchend: "mouseup",
    }[event.type], {
      bubbles: true, cancelable: true, view: window, detail: 1, composed: true,
      screenX: touch.screenX, screenY: touch.screenY, clientX: touch.clientX, clientY: touch.clientY,
      ctrlKey: false, altKey: false, shiftKey: false, metaKey: false, button: 0, buttons: 1, relatedTarget: null
    });
    touch.target.dispatchEvent(simulatedEvent);
    if(event.type === "touchend") {
      // add this action to prevent jump back to previous position
      touch.target.dispatchEvent(new MouseEvent("mousedown", {}));
    }
  }

gawinwong avatar Jun 01 '22 09:06 gawinwong

memo: URS-454

karasusan avatar Jun 07 '22 02:06 karasusan

@gawinwong Thanks reporting issue and suggestion for improvement. We will reproduce this issue and check InputSystem bug or WebApp implementation bug. If webapp implementation bug, we refer to your solution.

kannan-xiao4 avatar Jun 07 '22 02:06 kannan-xiao4