-
Creator 版本:3.5.2
-
目标平台:web
-
重现方式:重复创建2个场景,复制并打印Canvas的UUID,一样的。
-
首个报错:两个场景下的Canvas UUID一样。这样会导致一个bug,如果其中一个场景当常驻节点, 在常驻节点上面添加触摸节点时,触摸事件排序时,一直向上查找相同UUID的节点就认为是同一节点了,但是两个Canvas uuid一样,但并不是同一节点,就会导致触摸排序是错误的。(常驻节点在切换场景时,会添加到新场景的下面,和新场景Canvas同级)
private _sortByPriority (p1: NodeEventProcessor, p2: NodeEventProcessor) {
const node1: Node = p1.node;
const node2: Node = p2.node;
if (!p2 || !node2 || !node2.activeInHierarchy || !node2._uiProps.uiTransformComp) {
return -1;
} else if (!p1 || !node1 || !node1.activeInHierarchy || !node1._uiProps.uiTransformComp) {
return 1;
}
if (p1.cachedCameraPriority !== p2.cachedCameraPriority) {
return p2.cachedCameraPriority - p1.cachedCameraPriority;
}
let n1: Node | null = node1; let n2: Node | null = node2; let ex = false;
// @ts-expect-error _id is a protected property
while (n1.parent?._id !== n2.parent?._id) {
n1 = n1?.parent?.parent === null ? (ex = true) && node2 : n1 && n1.parent;
n2 = n2?.parent?.parent === null ? (ex = true) && node1 : n2 && n2.parent;
}
// @ts-expect-error protected property _id
if (n1._id === n2._id) {
// @ts-expect-error protected property _id
if (n1._id === node2._id) {
return -1;
}
// @ts-expect-error protected property _id
if (n1._id === node1._id) {
return 1;
}
}
const priority1 = n1 ? n1.getSiblingIndex() : 0;
const priority2 = n2 ? n2.getSiblingIndex() : 0;
return ex ? priority1 - priority2 : priority2 - priority1;
}