• RuntimesUnity
  • Repacking specific Atlases/Materials on a character

Hey there ! Hope you're all doing well !

I'm currently working on a character with multiple atlases/materials, and I'm facing a little problem. One of the character's materials (which contains his body's assets) doesn't use the same shader as the others, and his atlas must imperatively keep the same size and structure.
The other atlases/materials, which contain the character's equipment, must be repacked once the equipment has been selected.

So here's my question: is it possible to use Repacking for only certain atlases/materials? And then have one material for the body (the original one), and one repacked material for the equipment?

Related Discussions
...

Yes, it is possible to repack only certain atlases or materials while keeping others unchanged. You can achieve this by using the GetRepackedAttachments or GetRepackedSkin methods to repack only the attachments or skins that you want to change, such as the equipment, while leaving the body material and its atlas intact. This allows you to maintain the original shader and structure for the body material, while creating a new repacked material for the equipment. You can find more information on how to use these methods in the Spine Unity documentation.

How do I use the GetRepackedSkin method to repack only the skins that I want to change, such as the equipment, while leaving the body material and its atlas intact?

@termichator When creating a combined Skin from individual skin items (see Combining Skins in the spine-unity documentation), you could create one Skin to be repacked and add it to the combined skin instead of adding individual Skin items:

var skeleton = skeletonAnimation.Skeleton;
var skeletonData = skeleton.Data;

var mixAndMatchSkin = new Skin("custom-girl");
var repackedSkin = new Skin("repack");
mixAndMatchSkin.AddSkin(skeletonData.FindSkin("skin-base"));

repackedSkin.AddSkin(skeletonData.FindSkin("nose/short"));
repackedSkin.AddSkin(skeletonData.FindSkin("eyelids/girly"));
repackedSkin.AddSkin(skeletonData.FindSkin("eyes/violet"));
repackedSkin.AddSkin(skeletonData.FindSkin("hair/brown"));
repackedSkin.AddSkin(skeletonData.FindSkin("clothes/hoodie-orange"));
repackedSkin.AddSkin(skeletonData.FindSkin("legs/pants-jeans"));

repackedSkin = repackedSkin.GetRepackedSkin("repacked skin", sourceMaterial, out runtimeMaterial, out runtimeAtlas); // Pack all the items in the skin.
mixAndMatchSkin.AddSkin(repackedSkin);

skeleton.SetSkin(mixAndMatchSkin);
skeleton.SetSlotsToSetupPose();
skeletonAnimation.AnimationState.Apply(skeletonAnimation.Skeleton);

You just saved me ! Thanks !