button代码注册的事件要不要取消

例如:一个button 按钮用代码注册了事件,代码如下:find(“Canvas/bg/Button”).getComponent(Button).node.on(Button.EventType.CLICK,this.testOnclick,this);

场景销毁的时候需不需要把按钮注册的事件取消?

看源码,如果是node上面的会统一移除

node销毁时,绑定的事件自动销毁,如果需要手动取消

find(“Canvas/bg/Button”).getComponent(Button).node.off(Button.EventType.CLICK,this.testOnclick,this);

另外

find(“Canvas/bg/Button”).getComponent(Button).node === find(“Canvas/bg/Button”)

好的,谢谢