mirror of
https://github.com/tidys/cc-inspector-chrome
synced 2025-04-19 16:38:41 +00:00
兼容其他版本hitTest的逻辑
This commit is contained in:
parent
3118b86286
commit
ef970e9d4c
@ -65,7 +65,7 @@ export class HintAdapter {
|
|||||||
let node = new cc.Node("draw-node");
|
let node = new cc.Node("draw-node");
|
||||||
const canvas = cc.find("Canvas");
|
const canvas = cc.find("Canvas");
|
||||||
this.addDraw(scene, canvas, node);
|
this.addDraw(scene, canvas, node);
|
||||||
this.draw = node.addComponent(cc.Graphics);
|
this.draw = node.addComponent(cc.Graphics || cc.GraphicsComponent);
|
||||||
}
|
}
|
||||||
public isDrawValid() {
|
public isDrawValid() {
|
||||||
return this.draw && this.draw.isValid;
|
return this.draw && this.draw.isValid;
|
||||||
|
@ -8,8 +8,23 @@ export class HintV3 extends HintAdapter {
|
|||||||
node.setSiblingIndex(len);
|
node.setSiblingIndex(len);
|
||||||
}
|
}
|
||||||
hitTest(node: any, x: number, y: number): boolean {
|
hitTest(node: any, x: number, y: number): boolean {
|
||||||
let b = node._uiProps?.uiTransformComp?.hitTest({ x, y }, 0);
|
let hitTest = null;
|
||||||
|
// hitTest = node._uiProps?.uiTransformComp?.hitTest;
|
||||||
|
const tr = node.getComponent(cc.UITransformComponent || cc.UITransform);
|
||||||
|
if (tr) {
|
||||||
|
if (tr.hitTest) {
|
||||||
|
hitTest = tr.hitTest.bind(tr);
|
||||||
|
} else if (tr.isHit) {
|
||||||
|
// TODO: 3.3.1使用的是这个接口,hitTest有问题,有人反馈再说修复,老版本暂不花费太多精力
|
||||||
|
hitTest = tr.isHit.bind(tr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (hitTest) {
|
||||||
|
let b = hitTest({ x, y }, 0);
|
||||||
return b;
|
return b;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
convertMousePos(event: MouseEvent, canvas: HTMLCanvasElement): { x: number; y: number } {
|
convertMousePos(event: MouseEvent, canvas: HTMLCanvasElement): { x: number; y: number } {
|
||||||
const rect = canvas.getBoundingClientRect();
|
const rect = canvas.getBoundingClientRect();
|
||||||
|
@ -89,7 +89,7 @@ export class Hint {
|
|||||||
this.cleanSelected();
|
this.cleanSelected();
|
||||||
const nodes = this.getMouseNodes(event, canvas);
|
const nodes = this.getMouseNodes(event, canvas);
|
||||||
const pickTop = toRaw(appStore().config.pickTop);
|
const pickTop = toRaw(appStore().config.pickTop);
|
||||||
if (nodes.length === 1 || pickTop) {
|
if (nodes.length === 1 || (pickTop && nodes.length)) {
|
||||||
const item = nodes[0];
|
const item = nodes[0];
|
||||||
this.cleanHover();
|
this.cleanHover();
|
||||||
this.setSelected(item);
|
this.setSelected(item);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user