We're trying to implement a character system using Unity and Spine 4beta. The plan is to have an undressed body only, and lots of outfits for it (100s).
The simplest way would be to of course to create all outfits as skins for the body, but doing it the naive way would have us load all geometry / textures into memory, both of which would not be small. I went over similar posts in the forum, but would like to go over some ideas I have in order to help me avoid time trying to implement dead ends.
1) The first idea I had was to export the body as well as each outfit as a separate character (that means lots of assets of type SkeletonDataAsset). I tried quick prototype, then load body and an outfit to Unity and create a new skin for the body, but the outfit does not show. Is there some requirement for Skin to be only created from the same SkeletonDataAsset? I did something like this:
public SkeletonDataAsset Outfit;
SkeletonAnimation _bodySkeletonAnimation = SkeletonAnimation.NewSkeletonAnimationGameObject(Body);
var customSkin = new Skin("custom-skin");
var outfitSkeletonData = Outfit.GetSkeletonData(true);
var outfitSkin = outfitSkeletonData.DefaultSkin;
// add whole skin
// or add individual attachments (I tried both options)
foreach (var attachement in outfitSkin.Attachments)
customSkin.SetAttachment(attachement.SlotIndex, attachement.Name, attachement.Attachment);
Should this work or not? Alternatively, is there a way to make it work? Can I at runtime clone skin parts from the outfit to the body and create new skin after that or anything similar?
2) My alternative solution is more along the lines mentioned on the forum here. Create a single character, and create all outfits as skins. Have textures in folders, so that separate atlas is created for each outfit. Then before the build / bundle creation, I thought I'd replace the link to the texture by either null or some dummy 4x4 pixels texture. This way when I load SkeletonDataAsset, large textures won't load. Then I'll have to implement custom atlas loader, load the atlas texture and connect it to material .. is there some example on how to do this part please?
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?
I would prefer option 1 if possible, but option 2 is likely acceptable as well. Any other good option here?
Thanks so much!