Hi devteam,
I found onDestroy() is not called for a component when its node is deleted in the editor.
Here is simplest component to reproduce:
import { _decorator, Component } from 'cc';
const { ccclass, executeInEditMode } = _decorator;
@ccclass('NewComponent')
@executeInEditMode
export class NewComponent extends Component {
onLoad() {
console.error('onLoad()');
}
onEnable() {
console.error('onEnable()');
}
onDisable() {
console.error('onDisable()');
}
onDestroy() {
console.error('onDestroy()');
}
}
You can add this component to the empty node in the editor and delete the node afterward. The output in the console will be:
So, there is no onDestroy() called.
But it is called when you delete component itself from the node.