[3.3.1] Component.onDestroy() is not called when a node is deleted in the editor – #4 by pandamicro – Cocos Creator

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;

export class NewComponent extends Component {
    onLoad() {

    onEnable() {

    onDisable() {

    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.

Source link

More To Explore

Share on facebook
Share on twitter
Share on linkedin
Share on email