一个组件的onDestroy只有在真正的enable一次之后,才会被调用。
cc.Label中,如果在非enabled状态调用了_updateRenderData(true),那就会创建出_ttfTexture。如果此label并不被enable,而直接destroy,就会产生泄漏。需要在cc.Label中加上
_onPreDestroy () {
if (this._ttfTexture) {
this._ttfTexture.destroy();
this._ttfTexture = null;
}
cc.RenderComponent.prototype._onPreDestroy.call(this);
},
