设置父对象之前监听节点输入, 会导致该节点输入无效

版本 1.0.3, 很容易重现, 场寄及代码如下
Test.zip (3.8 KB)


import { _decorator, Component, Node, instantiate } from “cc”;
const { ccclass, property } = _decorator; @ccclass(“Test”)
export class Test extends Component {

@property(Node) pfb: Node = null;
@property isSetParentFirst = true;

start() {
    let newNode = instantiate(this.pfb) as Node;
    if (this.isSetParentFirst)
        newNode.parent = this.pfb.parent;
    newNode.on(Node.EventType.TOUCH_START, this.onTap, this);
    if (!this.isSetParentFirst)
    newNode.parent = this.pfb.parent;
    newNode.on(Node.EventType.TOUCH_END, this.onTap2, this);
}
onTap() {
    console.log("[Test][onTap]", this.node.name, this.isSetParentFirst);
}
onTap2() {
    console.log("[Test][onTap2]", this.node.name, this.isSetParentFirst);
}

}

同这个问题

1.1 开发版已经修复