Skip to content

Commit 8e64d3c

Browse files
committed
fix native crash by null material bug
1 parent 5690d1b commit 8e64d3c

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

cocos/particle/renderer/particle-system-renderer-cpu.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -747,6 +747,12 @@ export default class ParticleSystemRendererCPU extends ParticleSystemRendererBas
747747
this._defines[ROTATION_OVER_TIME_MODULE_ENABLE] = enable;
748748
this._defines[INSTANCE_PARTICLE] = this._useInstance;
749749

750+
const matIns: MaterialInstance | null = ps.getMaterialInstance(0);
751+
if (matIns === null || matIns === undefined) {
752+
ps.setSharedMaterial(mat.parent, 0); // set material[0] as material for ui-mesh-renderer to use
753+
ps.setMaterialInstance(mat, 0);
754+
}
755+
750756
mat.recompileShaders(this._defines);
751757
if (this._model) {
752758
this._model.updateMaterial(mat);

0 commit comments

Comments
 (0)