Open gawinwong opened 2 years ago
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", {}));
}
}
memo: URS-454
@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.
Package version
3.1.0-exp.3
Environment
Steps To Reproduce
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