From 5c72a79a02a4da0f10f0f87b6cd113ba61dcbffe Mon Sep 17 00:00:00 2001 From: SmallMain Date: Tue, 12 Jul 2022 11:44:01 +0800 Subject: [PATCH] =?UTF-8?q?[engine]=20=E4=BF=AE=E5=A4=8D=20Spine=20?= =?UTF-8?q?=E5=8A=A8=E6=80=81=E5=90=88=E5=9B=BE=E6=9C=AA=E5=88=A4=E6=96=AD?= =?UTF-8?q?=20attachment=20=E6=98=AF=E5=90=A6=E5=AD=98=E5=9C=A8=20region?= =?UTF-8?q?=20=E5=AF=B9=E8=B1=A1=E6=8A=A5=E9=94=99=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- engine/extensions/spine/spine-assembler.js | 62 +++++++++++----------- 1 file changed, 32 insertions(+), 30 deletions(-) diff --git a/engine/extensions/spine/spine-assembler.js b/engine/extensions/spine/spine-assembler.js index a7df0d23..661a930a 100644 --- a/engine/extensions/spine/spine-assembler.js +++ b/engine/extensions/spine/spine-assembler.js @@ -325,41 +325,43 @@ export default class SpineAssembler extends Assembler { } } else { const region = attachment.region; - const alreadyInAtlas = !!region._original; + if (region) { + const alreadyInAtlas = !!region._original; - if (alreadyInAtlas) { - // 可能出现多个 attachment 共用同一个 region - if (_packedRegions.includes(region)) { - this.updatePackedAttachment(attachment, false); - } - } else if (region.texture && region.texture._texture.packable) { - if (region._spriteFrame) { - const spriteFrame = region._spriteFrame; - region._spriteFrame = null; - spriteFrame.destroy(); - } - _tmpRegionData.initWithAttachment(attachment); - const frame = _tmpRegionData.toSpriteFrame(); - const packedFrame = cc.dynamicAtlasManager.insertSpriteFrame(frame); - if (packedFrame) { - frame._setDynamicAtlasFrame(packedFrame); - - region._original = { - _texture: region.texture, - _x: region.x, - _y: region.y, - _ref: 0, - }; + if (alreadyInAtlas) { + // 可能出现多个 attachment 共用同一个 region + if (_packedRegions.includes(region)) { + this.updatePackedAttachment(attachment, false); + } + } else if (region.texture && region.texture._texture.packable) { + if (region._spriteFrame) { + const spriteFrame = region._spriteFrame; + region._spriteFrame = null; + spriteFrame.destroy(); + } + _tmpRegionData.initWithAttachment(attachment); + const frame = _tmpRegionData.toSpriteFrame(); + const packedFrame = cc.dynamicAtlasManager.insertSpriteFrame(frame); + if (packedFrame) { + frame._setDynamicAtlasFrame(packedFrame); - region._spriteFrame = frame; + region._original = { + _texture: region.texture, + _x: region.x, + _y: region.y, + _ref: 0, + }; - _tmpRegionData.updateWithPackedFrame(packedFrame); + region._spriteFrame = frame; - this.updatePackedAttachment(attachment); + _tmpRegionData.updateWithPackedFrame(packedFrame); - _packedRegions.push(region); - } else { - frame.destroy(); + this.updatePackedAttachment(attachment); + + _packedRegions.push(region); + } else { + frame.destroy(); + } } } }