From 45fcb9f8976ff64f50475e15a2cab03868e14e21 Mon Sep 17 00:00:00 2001 From: GengineJS <476393671@qq.com> Date: Wed, 18 Dec 2024 11:14:09 +0800 Subject: [PATCH] restore --- cocos/2d/framework/ui-renderer.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cocos/2d/framework/ui-renderer.ts b/cocos/2d/framework/ui-renderer.ts index 1bb55a0e652..c202bed6a7c 100644 --- a/cocos/2d/framework/ui-renderer.ts +++ b/cocos/2d/framework/ui-renderer.ts @@ -320,6 +320,10 @@ export class UIRenderer extends Renderer { this.node.on(NodeEventType.ANCHOR_CHANGED, this._nodeStateChange, this); this.node.on(NodeEventType.SIZE_CHANGED, this._nodeStateChange, this); this.node.on(NodeEventType.PARENT_CHANGED, this._colorDirty, this); + // If the renderData is invalid, it needs to be rebuilt to recalculate the batch processing. + if (!this._renderData && this._flushAssembler) { + this._flushAssembler(); + } this.updateMaterial(); this._colorDirty(); uiRendererManager.addRenderer(this); @@ -337,6 +341,9 @@ export class UIRenderer extends Renderer { this.node.off(NodeEventType.ANCHOR_CHANGED, this._nodeStateChange, this); this.node.off(NodeEventType.SIZE_CHANGED, this._nodeStateChange, this); this.node.off(NodeEventType.PARENT_CHANGED, this._colorDirty, this); + // When disabling, it is necessary to free up idle space to fully utilize chunks + // and avoid breaking batch processing. + this.destroyRenderData(); uiRendererManager.removeRenderer(this); this._renderFlag = false; this._renderEntity.enabled = false;