Yes, you can export meshes without specific attachments and assign images later in Unity using linked meshes.
Here's how it works:
In Spine:
- Create your first mesh with the initial image
- Create a linked mesh from it
- Rename the linked mesh so it references a different image
Both the original mesh and all linked meshes share the same vertices, mesh weights, and deform timelines, so they work perfectly for swappable items.
For export:
- You need to export the source mesh attachments because linked meshes depend on them
- The source meshes will export even if
Export is unchecked (though you'll get a warning)
- If you don't have images for the source meshes, you can set the
Path for your source meshes to any existing image in your project - this ensures a texture region is found at runtime
In Unity:
Once exported, you can swap attachments at runtime using the spine-unity API. You can:
- Use
attachment.GetRemappedClone to create a clone of an attachment mapped to a different texture (using a UnityEngine.Sprite or AtlasRegion)
- Use
meshAttachment.GetLinkedMesh to create new linked meshes with different texture sources
- Assign these new attachments to slots as needed
This approach is ideal for mix-and-match systems with multiple swappable items like jackets, since all variants share the same mesh structure and animations.