As shown in image I have LeftSide and RightSide UI image element with User Input Enabled.
When i click and go extreme left or right my mouseenter event gets triggered and when i leave left or right area mouseleave event get trigged which works fine for pc.
this.autoDragLeftAreaComp.element.on('mouseenter', function (evt) {
console.log("autoDragLeftAreaComp ENTER");
}, this);
this.autoDragRightAreaComp.element.on('mouseenter', function (evt) {
console.log("autoDragRightAreaComp ENTER");
}, this);
this.autoDragLeftAreaComp.element.on('mouseleave', function (evt) {
console.log("autoDragLeftAreaComp LEFT");
}, this);
this.autoDragRightAreaComp.element.on('mouseleave', function (evt) {
console.log("autoDragRightAreaComp LEFT");
}, this);
Basically i am clicking and dragging the screen to reach left and right area.
How i can make UI element work like mouse enter / mouse leave on Touch Device?
(Is this possible without raycast and colliders?)
There’s isn’t and I’m not sure why there isn’t a parity between the mouse and touch on the elements TBH
You might be better off using screen position instead here unfortunately. I can’t think off the top of my head how this would work with elements and touch
You can use the screen coordinates of the mouse/touch events and see if it is on the 0-10% or the 90-100% of the screen. Or rather than %, you can use actual pixel values.