Node created at runtime show up in Creator and got saved to the scene

I use this code to create a node dynamically at runtime.

this._transitionNode = new cc.Node();
this._transitionNode.parent = this.target;
this._transitionNode.zIndex = -1;
this._transitionNode.opacity = 0;
this._transitionSprite = this._transitionNode.addComponent(cc.Sprite);

It works great but when it runs, the node being created show up in Creator and got saved into the scene. Is it a creator bug?

Make sure you’re not using executeInEditMode flag or inherit from basic components as cc.Sprite (because they all use this flag).
Try wrapping it with if( !CC_EDITOR) check

1 Like