Coincidentally, I ran into this same error you've been seeing - the one where you get the NULL reference exception. The problem was I had a slot that had no attachment. It's a bug in the tk2dSpineSkeleton code at the following lines:
Attachment attachment = skeleton.DrawOrder[i].Attachment;
Material currentMaterial = skeletonDataAsset.spritesData.GetSpriteDefinition(attachment.Name).material;
The first line gets the attachment from the slot, which returns NULL. Then on the next line it tries to call the Name member on the attachment and bam, error.
You can fix this problem in one of two ways:
- In the spine editor by looking for any slots with no attachments and then deleting them.
- You can fix it in the tk2dSpineSkeleton.cs file by inserting the following check after you get the attachment,
Attachment attachment = skeleton.DrawOrder[i].Attachment;
if(attachment != null)
{
Material currentMaterial = skeletonDataAsset.spritesData.GetSpriteDefinition(attachment.Name).material;
....to the end of the for block
}
I would update the code myself in the repo, but I don't think I have permission to change it.
For the issue with your 3rd sprite, I'm not sure on that one 🙂. It's all on a single atlas right? Even if it wasn't, I think multi atlas support was added recently for spine tk2d runtime so it should work regardless.
Edit: Also, did you disable trimming in the SpriteCollection settings? I'm assuming yes, but if you enable trimming then the sprites will be drawn in the wrong locations on your spine character.