I’m developing a 2D multiplayer game in Unity using spine-unity, and I’d like some guidance on memory / atlas management for a character system with many outfits and full mix-and-match.
Project requirements
Each character is built with Spine.
There will be hundreds of outfits in the future.
Outfits are fully mix-and-match per body part, e.g.:
skin color, eyes, eyebrows, face, makeup, mouth
hair, clothes, bag, balloon, eyeglass, shoes
In a match, there can be up to 60 players on screen, each with their own customized outfit.
I’m using YooAsset for runtime loading and hot-update.
Current setup
Right now, my artist exports:
One “base” SkeletonDataAsset (body + face parts, multiple skins: skincolor/xxx, eyes/xxx, etc.)
Separate SkeletonDataAssets for each part:
hairDataAsset, clothesDataAsset, bagDataAsset, balloonDataAsset, eyeglassDataAsset, shoesDataAsset
All these skeletons share the same bones / skeleton structure.
On the Unity side I have a SpineAvatarManager that:
Creates a Skin customSkin = new Skin("custom-avatar");
AddSkin from the different SkeletonDataAssets, for example:
customSkin.AddSkin(baseData.FindSkin(skincolor));
customSkin.AddSkin(baseData.FindSkin(eyes));
...
customSkin.AddSkin(hairData.FindSkin(hair));
customSkin.AddSkin(clothesData.FindSkin(clothes));
...
skeleton.SetSkin(customSkin);
skeleton.SetSlotsToSetupPose();
animationState.Apply(skeleton);
(Optionally) does GetRepackedSkin to generate a single material/atlas for that avatar.
I’ve read the docs and these threads:
Memory management of character with many outfits
https://esotericsoftware.com/forum/d/15867-memory-management-of-character-with-many-outfits/16
Delayed on-demand loading of Atlas assets (#1890)
EsotericSoftware/spine-runtimes1890
From these I understand:
I should remove any (indirect) references to atlas textures from scenes/prefabs, e.g. set Skeleton materials’ mainTexture to a small dummy texture, so Unity doesn’t auto-load all outfit textures.
When needed, I should load the real atlas textures via Addressables/AssetBundles/YooAsset and plug them back into the Materials (and maybe use the experimental on-demand loading package).
What I’m unsure about
Given my case (hundreds of outfits + 60 players), I’d like to ask:
Is my multi-SkeletonData approach OK?
One base SkeletonData + separate SkeletonDataAssets for hair / clothes / bag / shoes etc., all sharing the same bones, combined with Skin.AddSkin on the main skeleton.
Is this a recommended approach for large mix-and-match systems, or would you suggest using one big SkeletonData with all attachments in different skins instead?
Repacking strategy for 60 players
If I call GetRepackedSkin for every customized player, I may end up with 60 different runtime atlases, which seems heavy in terms of memory.
In your experience, is it better to:
Only repack the local player (and maybe a few important characters), and let other players use multi-material skins?
Or try to reuse repacked skins when multiple players share the same combination (same outfit ID), and only create a new repack for unique combinations?
Best practice for atlas texture loading/unloading
Right now, to avoid Unity auto-loading all textures, I’m planning to:
In Editor: replace all Spine atlas materials’ mainTexture with a 2×2 dummy texture, so scenes/prefabs don’t reference the full textures.
At runtime: when a certain outfit is needed, load the actual atlas texture via YooAsset and assign it back to the correct SpineAtlasAsset.Materials.
Is this approach recommended, or should I rely only on the experimental delayed on-demand loading package mentioned in issue #1890?
Any advice on how to combine the experimental on-demand loading with Addressables/AssetBundles/YooAsset correctly?
Official sample or reference
Is there any official sample or recommended pattern that demonstrates:
A character with many outfits,
Mix-and-match skins across body parts,
And runtime loading/unloading of atlas textures via Addressables/AssetBundles (or similar)?
Any guidance on architecture and best practices (especially around memory usage vs. draw calls vs. repacking) would be greatly appreciated.
Thank you for your time!