diff --git a/engine/cocos2d/core/renderer/assembler.js b/engine/cocos2d/core/renderer/assembler.js index 12d30d30..a3109113 100644 --- a/engine/cocos2d/core/renderer/assembler.js +++ b/engine/cocos2d/core/renderer/assembler.js @@ -69,7 +69,7 @@ export default class Assembler { if (CC_JSB) comp.node._inJsbDirtyList = false; // setMaterial 中会置 comp._texIdDirty = true; if (!this.isMulti) { - comp._assembler.updateRenderDataForSwitchMaterial(comp); + if (comp._assembler) comp._assembler.updateRenderDataForSwitchMaterial(comp); return true; } } diff --git a/engine/cocos2d/core/renderer/utils/label/letter-font.js b/engine/cocos2d/core/renderer/utils/label/letter-font.js index a0766aee..b90534e3 100644 --- a/engine/cocos2d/core/renderer/utils/label/letter-font.js +++ b/engine/cocos2d/core/renderer/utils/label/letter-font.js @@ -448,6 +448,10 @@ class LetterAtlases { const atlas = letter.atlas; const comp = _assembler._renderComp; + if (!_usedMaterial) { + return; + } + // 检查是否需要自动切换材质 if (_needCheckMaterial) { _needCheckMaterial = false; @@ -605,7 +609,7 @@ export default class LetterFontAssembler extends WebglBmfontAssembler { const verts = renderData.vDatas[0]; const floatsPerVert = this.floatsPerVert; 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; texIdOffset += floatsPerVert;