/**
* @en For non-UI component display object nodes (container objects or display objects without image resources), specifies whether the mouse events penetrate this object's collision detection. `true` means the object is penetrable, `false` means it is not penetrable.
* When penetrable, the engine will no longer detect this object and will recursively check its child objects until it finds the target object or misses all objects.
* When not penetrable, the node's width and height define the mouse collision area (a non-penetrable rectangular area). If the rectangular collision area does not meet the requirements, you can use the drawing area of the hit area as the collision area. The hit area takes precedence over width and height of node as the non-penetrable mouse collision area.
* Note that for UI object nodes with a set skin property, once a skin texture resource is set, this property becomes ineffective, and the rectangular area drawn by the texture will always be non-penetrable unless it does not accept mouse events or a non-clickable area is set.
* @ZH 用于非UI组件显示对象节点(容器对象或没有设置图像资源的显示对象),鼠标事件与此对象在碰撞检测时,是否穿透。ture为可穿透,false为不可穿透。
* 可穿透时,引擎不再检测本对象,而会递归检测子对象,直到找到命中的目标对象或者未命中任何对象。
* 不可穿透时,以节点宽高为鼠标碰撞区(矩形的不可穿透区域)。如果矩形碰撞区不能满足需求,可以将点击区域的绘制图形作为碰撞区,绘制区域优先于宽高作为不可穿透的鼠标碰撞区域。
* 注意,可以设置skin属性的UI对象节点,当设置了skin纹理资源之后,该属性设置失效,纹理绘制的矩形区域内会始终处于不可穿透状态。除非不接受鼠标事件或设置不可点击区域。
*/
mouseThrough: boolean = false;
1 个回复
Laya_Fred
赞同来自:
1、复现demo逻辑中,先设置了node2也就是t2预制体实例的mouse Through为true,而后设置了node2的子节点0(GWidget的实例)纹理texture为new Laya.Texture。设置纹理之后,mouseThrough的设置就无效了,可以参考Laya.Sprite的mouseThrogh的注释,如下所示:
* 当设置纹理资源之后,这个属性设置无效了,可以设置不接收鼠标事件或者设置不可点击区域来处理
2、对应到demo中,将node2的子节点0的texture去掉之后就点击事件可以回调了,或者设置node2子节点0的不接收鼠标事件也可以进行事件的回调了,所以最新版本的事件回调处理是符合预期的哈。