[engine] 修复某些情况下渲染组件未就绪导致的报错问题

This commit is contained in:
SmallMain 2022-07-05 11:07:42 +08:00
parent 3f8f7ffd34
commit 654d0bd634
2 changed files with 6 additions and 2 deletions

View File

@ -69,7 +69,7 @@ export default class Assembler {
if (CC_JSB) comp.node._inJsbDirtyList = false; if (CC_JSB) comp.node._inJsbDirtyList = false;
// setMaterial 中会置 comp._texIdDirty = true; // setMaterial 中会置 comp._texIdDirty = true;
if (!this.isMulti) { if (!this.isMulti) {
comp._assembler.updateRenderDataForSwitchMaterial(comp); if (comp._assembler) comp._assembler.updateRenderDataForSwitchMaterial(comp);
return true; return true;
} }
} }

View File

@ -448,6 +448,10 @@ class LetterAtlases {
const atlas = letter.atlas; const atlas = letter.atlas;
const comp = _assembler._renderComp; const comp = _assembler._renderComp;
if (!_usedMaterial) {
return;
}
// 检查是否需要自动切换材质 // 检查是否需要自动切换材质
if (_needCheckMaterial) { if (_needCheckMaterial) {
_needCheckMaterial = false; _needCheckMaterial = false;
@ -605,7 +609,7 @@ export default class LetterFontAssembler extends WebglBmfontAssembler {
const verts = renderData.vDatas[0]; const verts = renderData.vDatas[0];
const floatsPerVert = this.floatsPerVert; const floatsPerVert = this.floatsPerVert;
let texIdOffset = offset + this.texIdOffset; let texIdOffset = offset + this.texIdOffset;
const id = _usedMaterial.material !== _shareAtlas.material ? letter.atlas._tmpId : letter.atlas._id; const id = !_usedMaterial ? 0 : (_usedMaterial.material !== _shareAtlas.material ? letter.atlas._tmpId : letter.atlas._id);
verts[texIdOffset] = id; verts[texIdOffset] = id;
texIdOffset += floatsPerVert; texIdOffset += floatsPerVert;