Skip to content

Commit

Permalink
Fix an error of mesh.renderingSubMeshes is undefined (#16539)
Browse files Browse the repository at this point in the history
* Fix an error of mesh.renderingSubMeshes is undefined

* Update renderingSubMeshes checking logic
  • Loading branch information
dumganhar authored Nov 27, 2023
1 parent 5e0764a commit 96a1b61
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cocos/2d/framework/sprite-renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,9 @@ export class SpriteRenderer extends ModelRenderer {
const mesh = this._spriteFrame.mesh!;
this.node.hasChangedFlags |= TransformBit.POSITION; // Same as model, Maybe a hack
this._model.transform.hasChangedFlags |= TransformBit.POSITION;
const meshCount = mesh ? mesh.renderingSubMeshes.length : 0;
const renderingMesh = mesh.renderingSubMeshes;
const renderingMesh = mesh ? mesh.renderingSubMeshes : null;
if (renderingMesh) {
const meshCount = renderingMesh.length;
for (let i = 0; i < meshCount; ++i) {
let material = this.getRenderMaterial(i);
if (material && !material.isValid) {
Expand Down

0 comments on commit 96a1b61

Please sign in to comment.