Tuesday, January 28, 2025
spot_img

What「The asset has been destroyed!」 – Cocos Creator


Within the browser, I executed the next code to delete a node.

this.node.destroy();”

Then the message “The asset has been destroyed!” seems within the console.
Each time I delete a node, I get 3 or 4 of those messages.
I created a venture that solely does this.node.destroy();” in every of Cocos ‘3.8.2’ and ‘3.8.3’, however it nonetheless occurs.

Additionally, the outline within the documentation that the node doesn’t delete itself, however reasonably deletes itself from different nodes, didn’t work.

This isn’t an error, however it appears very dangerous and is certainly not one thing you need to show.

Are you aware what causes this to seem or what might be executed about it?

https://docs.cocos.com/creator/3.8/handbook/en/scripting/life-cycle-callbacks.html,For each element in Cocos, has its life-cycle. In fact it is best to know clearly the node, when it will likely be created, and when it will likely be destroyed. Please be certain each time you name this.node.destroy, the node is legitimate. Simply in case, it’s higher so that you can add isValid() to evaluate whether or not the node is legitimate.

The next easy code is executed on the push of a button, however the ‘The asset has been destroyed!’ message continues to be displayed

@ccclass('TestButton')
export class TestButton extends Part {
  selectButton() {
    if (this.node.isValid) {
      log('Do destroy');
      this.node.destroy();
    }
  }
}

this.node.isValid() is a technique, not a property. Put the brackets.

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisement -spot_img

Latest Articles