diff --git a/cocos/2d/renderer/render-data.ts b/cocos/2d/renderer/render-data.ts index e8578db0a28..c6de48b3fb8 100644 --- a/cocos/2d/renderer/render-data.ts +++ b/cocos/2d/renderer/render-data.ts @@ -484,7 +484,9 @@ export class RenderData extends BaseRenderData { // Hack Do not update pre frame if (JSB && this.multiOwner === false) { if (DEBUG) { - assert(this._renderDrawInfo.render2dBuffer.length === this._floatStride * this._data.length, 'Vertex count doesn\'t match.'); + if (this._renderDrawInfo && this._renderDrawInfo.render2dBuffer) { + assert(this._renderDrawInfo.render2dBuffer.length === this._floatStride * this._data.length, 'Vertex count doesn\'t match.'); + } } // sync shared buffer to native this._renderDrawInfo.fillRender2dBuffer(this._data); diff --git a/cocos/2d/renderer/render-draw-info.ts b/cocos/2d/renderer/render-draw-info.ts index df0546389d8..45a0402cb6a 100644 --- a/cocos/2d/renderer/render-draw-info.ts +++ b/cocos/2d/renderer/render-draw-info.ts @@ -90,7 +90,7 @@ export class RenderDrawInfo { protected declare _uint32SharedBuffer: Uint32Array; // SharedBuffer of pos/uv/color - protected declare _render2dBuffer: Float32Array; + protected _render2dBuffer: Float32Array | null = null; constructor (nativeDrawInfo?: NativeRenderDrawInfo) { this.init(nativeDrawInfo); @@ -107,7 +107,7 @@ export class RenderDrawInfo { return this._nativeObj; } - get render2dBuffer (): Float32Array { + get render2dBuffer (): Float32Array | null { return this._render2dBuffer; } @@ -301,6 +301,9 @@ export class RenderDrawInfo { public fillRender2dBuffer (vertexDataArr: IRenderData[]): void { if (JSB) { + if (!this._render2dBuffer) { + return; + } const fillLength = Math.min(this._vbCount, vertexDataArr.length); let bufferOffset = 0; for (let i = 0; i < fillLength; i++) {