[LayaAir 2.0]3D 鼠标检测 错乱

环境:layaair:2.4.0  unity:2019.2.13f1
laya加载unity场景之后 在创建出来的3D物体添加 自定义脚本ObjClick,实现 onMouseClick和onMouseEnter事件
onMouseClick结果:鼠标双击检测正确,鼠标点击检测错乱
onMouseEnter结果:鼠标点击正确,我的理解 这个不应该是鼠标进入这个物体,而不是点击
drag等事件检测均为错乱
 
已邀请:

Aar0n

赞同来自:

照这个改一下试试 ,这块代码是 as自动转换丢了赋值

凉城

赞同来自:

123456.png

这里就是这样子的

凉城

赞同来自:

解决了 修改laya.d3.js _update方法为
_update() {
var i=0,n=0,j=0,m=0;
n=this._eventList.length;
var cameras=this._scene._cameraPool;
if (n > 0){
for (i=0;i < n;i++){
var e=this._eventList;
switch (e.type){
case "mousedown":
this._mouseTouchDown();
break ;
case "mouseup":
this._mouseTouchUp();
break ;
case "mousemove":;
var mousePoint=Input3D._tempPoint;
mousePoint.setTo(e.pageX,e.pageY);
Laya.stage._canvasTransform.invertTransformPoint(mousePoint);
this._mouseTouch.mousePositionX=mousePoint.x;
this._mouseTouch.mousePositionY=mousePoint.y;
this._mouseTouchRayCast(cameras);
break ;
case "touchstart":;
var lastLength=this._touches.length;
this._changeTouches(e.changedTouches,0);
this._mouseTouchRayCast(cameras);
(lastLength===0)&& (this._mouseTouchDown());
break ;
case "touchend":
case "touchcancel":
this._changeTouches(e.changedTouches,1);
(this._touches.length===0)&& (this._mouseTouchUp());
break ;
case "touchmove":
this._changeTouches(e.changedTouches,2);
this._mouseTouchRayCast(cameras);
break ;
default :
throw "Input3D:unkonwn event type.";
}
}
this._eventList.length=0;
};
var mouseTouch=this._mouseTouch;
var pressedSprite=mouseTouch._pressedSprite;
if (pressedSprite && (Laya.Stat.loopCount > mouseTouch._pressedLoopCount)){
var pressedScripts=pressedSprite._scripts;
if (pressedScripts){
for (j=0,m=pressedScripts.length;j < m;j++)
pressedScripts[j].onMouseDrag();
}
};
var touchSprite=mouseTouch.sprite;
if (touchSprite){
var scripts=touchSprite._scripts;
if (scripts){
for (j=0,m=scripts.length;j < m;j++)
scripts[j].onMouseOver();
}
}
}

 具体修改位置如图
修改.png


希望在下个版本的时候官方可以修复

要回复问题请先

商务合作
商务合作