diff --git a/cocos/2d/assembler/label/bmfontUtils.ts b/cocos/2d/assembler/label/bmfontUtils.ts index 09735a7d9b3..7e81ed09f82 100644 --- a/cocos/2d/assembler/label/bmfontUtils.ts +++ b/cocos/2d/assembler/label/bmfontUtils.ts @@ -117,13 +117,14 @@ export const bmfontUtils = { // TextProcessing processing.processingString(true, style, layout, outputLayoutData, comp.string); // generateVertex - this.resetRenderData(comp); outputRenderData.quadCount = 0; processing.generateRenderInfo(true, style, layout, outputLayoutData, outputRenderData, comp.string, this.generateVertexData); - - renderData.dataLength = outputRenderData.quadCount; - renderData.resize(renderData.dataLength, renderData.dataLength / 2 * 3); + if (renderData.dataLength !== outputRenderData.quadCount) { + this.resetRenderData(comp); + renderData.dataLength = outputRenderData.quadCount; + renderData.resize(renderData.dataLength, renderData.dataLength / 2 * 3); + } const datalist = renderData.data; for (let i = 0, l = outputRenderData.quadCount; i < l; i++) { datalist[i] = outputRenderData.vertexBuffer[i]; @@ -136,7 +137,14 @@ export const bmfontUtils = { _comp.actualFontSize = style.actualFontSize; _uiTrans.setContentSize(outputLayoutData.nodeContentSize); this.updateUVs(comp);// dirty need - this.updateColor(comp); // dirty need + // It is reasonable that the '_comp.node._uiProps.colorDirty' interface should be used. + // But this function is not called when just modifying the opacity. + // So the value of '_comp.node._uiProps.colorDirty' does not change. + // And _uiProps.colorDirty is synchronized with renderEntity.colorDirty. + if (_comp.renderEntity.colorDirty) { + this.updateColor(comp); // dirty need + _comp.node._uiProps.colorDirty = false; + } renderData.vertDirty = false; _comp = null; diff --git a/cocos/2d/renderer/render-entity.ts b/cocos/2d/renderer/render-entity.ts index 8bd35121b4c..706d30f6563 100644 --- a/cocos/2d/renderer/render-entity.ts +++ b/cocos/2d/renderer/render-entity.ts @@ -122,6 +122,10 @@ export class RenderEntity { protected _colorDirty = true; get colorDirty (): boolean { + if (JSB) { + // Synchronize values set from native to JS + this._colorDirty = !!this._boolSharedBuffer[RenderEntityBoolSharedBufferView.colorDirty]; + } return this._colorDirty; } set colorDirty (val: boolean) {