diff --git a/native/cocos/editor-support/spine-creator-support/SkeletonRenderer.cpp b/native/cocos/editor-support/spine-creator-support/SkeletonRenderer.cpp index b0d8b793fea..9fce3a69252 100644 --- a/native/cocos/editor-support/spine-creator-support/SkeletonRenderer.cpp +++ b/native/cocos/editor-support/spine-creator-support/SkeletonRenderer.cpp @@ -1024,6 +1024,7 @@ void SkeletonRenderer::updateRegion(const std::string &slotName, cc::middleware: if (_skeleton) { auto slot = _skeleton->findSlot(slotName.c_str()); auto attachment = slot->getAttachment(); + if (!attachment) return; attachment = attachment->copy(); slot->setAttachment(attachment); @@ -1067,12 +1068,17 @@ void SkeletonRenderer::updateRegion(const std::string &slotName, cc::middleware: mesh->setRegionRotate(true); mesh->setRegionDegrees(0); mesh->updateUVs(); - auto attachmentVertices = reinterpret_cast(mesh->getRendererObject()); - attachmentVertices = attachmentVertices->copy(); - mesh->setRendererObject(attachmentVertices); - attachmentVertices->_texture = texture; + + auto *attachmentVertices = new AttachmentVertices( + texture, + static_cast(mesh->getWorldVerticesLength() >> 1), + mesh->getTriangles().buffer(), + static_cast(mesh->getTriangles().size()) + ); texture->addRef(); + mesh->setRendererObject(attachmentVertices); + V3F_T2F_C4B *vertices = attachmentVertices->_triangles->verts; for (size_t i = 0, ii = 0, nn = mesh->getWorldVerticesLength(); ii < nn; ++i, ii += 2) { vertices[i].texCoord.u = mesh->getUVs()[ii];