dreamau wroteNote that skeletons in both files match (completely or mostly), so I was assuming at least some outfit parts would show.
If both files contain the same Slots, it is expected to work. [Edit: Attachments don't need to exist in both, these can only exist in the skin's skeleton data]
I just tested this locally with two exports of the Goblins
project (one with all skins deleted), using your script with the adaptation of
var outfitSkin = outfitSkeletonData.FindSkin("goblingirl");
instead of
var outfitSkin = outfitSkeletonData.DefaultSkin;
It successfully displayed the goblingirl skin for me.
What kind of error message or exception do you get? Are you sure that your Slots and Attachments match?
Could you perhaps send us the problematic exported assets (or a minimal Unity project)? You can send it as a zip file to contact@esotericsoftware.com
One more solution (a bit more complex however) would also be to programmatically concatenate json files before loading, or appending content of your Skins skeletonData after loading. This is briefly mentioned here on this forum thread:
多个spine共享一套骨骼动作
Regarding your second solution:
FYI: We have an issue ticket that deals with implementing delayed (partial) loading of atlas textures:
https://github.com/EsotericSoftware/spine-runtimes/issues/1890
The disadvantage here is that I need to load whole SkeletonDataAsset, which contains the meshes and some other data for all outfits, and I suspect this file will not be tiny. Can this be stores as binary to avoid parsing cost at least perhaps?
The skeleton .json
or binary .skel.bytes
file size should not be the problem usually. You can export it as binary:
Export - Spine User Guide: Data
Removing or replacing texture references from an atlas and loading the textures on-demand would be a viable solution. It basically would require to creating a wrapper around SetSkin
calls that ensures to load/unload textures and hook up the references as you described. It should not be necessary to write your own AttachmentLoader, replacing texture references depending on the next skin to be set should be easier to implement and sufficient for many use cases.