Use a better approach to address the issue in PR #18052, while fixing the problem where material cannot be read in the onEnable callback. (#18976)

This commit is contained in:
zhefeng.zhang
2025-09-12 17:09:51 +08:00
committed by GitHub
parent 73712a86c0
commit 5cb46cee5d
2 changed files with 2 additions and 4 deletions
+1 -1
View File
@@ -1027,7 +1027,7 @@ export class Label extends UIRenderer {
if (!this.renderData) {
if (this._assembler && this._assembler.createData) {
this._renderData = this._assembler.createData(this) as RenderData;
this.renderData!.material = this.material;
this.renderData!.material = this.getRenderMaterial(0);
this._updateColor();
}
}
+1 -3
View File
@@ -398,9 +398,7 @@ 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._destroyData();
this.destroyRenderData();
uiRendererManager.removeRenderer(this);
this._renderFlag = false;
this._renderEntity.enabled = false;