Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the issue where UI batching breaks under specific conditions. #17900

Merged
merged 2 commits into from
Nov 22, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions cocos/2d/framework/ui-renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -337,6 +341,11 @@ 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.
if (this._renderData) {
this.destroyRenderData();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

destroyRenderData() already check _renderData, so don't have check it here again.

}
uiRendererManager.removeRenderer(this);
this._renderFlag = false;
this._renderEntity.enabled = false;
Expand Down
Loading