如题,官方示例即可重现:
https://github.com/cocos-creator/test-cases-3d/blob/master/assets/cases/ui/08.mask/graphics-mask.scene
在Mask内部加入一个按钮,点击事件无效。
当Type为RECT或ELLIPSE时正常
查看源码,原因是 mask-component.ts 299行被注释了的原因。
如题,官方示例即可重现:
https://github.com/cocos-creator/test-cases-3d/blob/master/assets/cases/ui/08.mask/graphics-mask.scene
在Mask内部加入一个按钮,点击事件无效。
当Type为RECT或ELLIPSE时正常
查看源码,原因是 mask-component.ts 299行被注释了的原因。
临时解决方案:
let originalIsHit = MaskComponent.prototype.isHit;
MaskComponent.prototype.isHit = function (this: MaskComponent, cameraPt) {
if (this._type === MaskComponent.Type.GRAPHICS_STENCIL) {
this._type = MaskComponent.Type.RECT;
let result = originalIsHit.call(this, cameraPt);
this._type = MaskComponent.Type.GRAPHICS_STENCIL;
return result;
}
else {
return originalIsHit.call(this, cameraPt);
}
}
感谢反馈~