mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-19 14:52:40 +08:00
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:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user