diff --git a/engine/cocos2d/core/renderer/utils/dynamic-atlas/manager.js b/engine/cocos2d/core/renderer/utils/dynamic-atlas/manager.js index 801337a6..5e0a578b 100644 --- a/engine/cocos2d/core/renderer/utils/dynamic-atlas/manager.js +++ b/engine/cocos2d/core/renderer/utils/dynamic-atlas/manager.js @@ -366,6 +366,36 @@ let dynamicAtlasManager = { _atlases[i].update(); } }, + + getUnusedAtlas() { + if (!this.enabled) return null; + + for (let i = 0; i <= _atlasIndex; i++) { + if (_atlases[i].isEmpty()) { + return _atlases[i]; + } + } + + return null; + }, + + deleteAtlas(index) { + if (!this.enabled) return; + + _atlases[index].destroy(); + _atlases.splice(index, 1); + _atlasIndex--; + }, + + destroyUnusedAtlases() { + if (!this.enabled) return; + + for (let i = 0; i <= _atlasIndex; i++) { + if (_atlases[i].isEmpty()) { + _atlases[i].destroy(); + } + } + }, }; /** diff --git a/engine/cocos2d/core/renderer/utils/dynamic-atlas/reusable-atlas.ts b/engine/cocos2d/core/renderer/utils/dynamic-atlas/reusable-atlas.ts index 76900799..a4e77902 100644 --- a/engine/cocos2d/core/renderer/utils/dynamic-atlas/reusable-atlas.ts +++ b/engine/cocos2d/core/renderer/utils/dynamic-atlas/reusable-atlas.ts @@ -623,6 +623,8 @@ export class Atlas { /** * 销毁 + * + * 请勿直接调用 */ destroy() { this.reset(); diff --git a/engine/cocos2d/core/sp/multi-batcher.ts b/engine/cocos2d/core/sp/multi-batcher.ts index dd18ab2f..ef85280c 100644 --- a/engine/cocos2d/core/sp/multi-batcher.ts +++ b/engine/cocos2d/core/sp/multi-batcher.ts @@ -61,10 +61,11 @@ export class MultiBatcher { /** - * 重置多纹理材质数组,再次使用请先初始化 + * 重置 */ reset() { this.handlers.length = 0; + this.nextHandler = null!; } }