We are sorry for the confusion, thanks for the feedback. We will add a new example scene that shows combining skins for more clarity.
MichelVictor लिखाWhat I expeted is that when I change the skins and combine it, they see what images I'm using from the atlas and create a new atlas from this images, not from unity, but directly from the spine atlas.
This is what happens actually, it will use the used items and create a new atlas from it, regardless where they come from.
Use e.g. the following code to combine multiple skins to a new skin, packed to a single atlas texture from one or more Spine atlas source textures:
private void Start () {
var skeleton = skeletonAnimation.Skeleton;
var skeletonData = skeleton.data;
var mixAndMatchSkin = new Skin("custom-girl");
mixAndMatchSkin.AddSkin(skeletonData.FindSkin("skin-base"));
mixAndMatchSkin.AddSkin(skeletonData.FindSkin("nose/short"));
mixAndMatchSkin.AddSkin(skeletonData.FindSkin("eyelids/girly"));
mixAndMatchSkin.AddSkin(skeletonData.FindSkin("eyes/violet"));
mixAndMatchSkin.AddSkin(skeletonData.FindSkin("hair/brown"));
mixAndMatchSkin.AddSkin(skeletonData.FindSkin("clothes/hoodie-orange"));
mixAndMatchSkin.AddSkin(skeletonData.FindSkin("legs/pants-jeans"));
mixAndMatchSkin.AddSkin(skeletonData.FindSkin("accessories/bag"));
mixAndMatchSkin.AddSkin(skeletonData.FindSkin("accessories/hat-red-yellow"));
bool repack = true;
if (repack) {
Material runtimeMaterial;
Texture2D runtimeAtlas;
Skin repackedSkin = mixAndMatchSkin.GetRepackedSkin("Repacked skin", skeletonAnimation.SkeletonDataAsset.atlasAssets[0].PrimaryMaterial, out runtimeMaterial, out runtimeAtlas);
mixAndMatchSkin.Clear();
// Use the repacked skin.
skeletonAnimation.Skeleton.Skin = repackedSkin;
skeletonAnimation.Skeleton.SetSlotsToSetupPose();
skeletonAnimation.AnimationState.Apply(skeletonAnimation.Skeleton);
}
else {
skeleton.SetSkin(mixAndMatchSkin);
skeleton.SetSlotsToSetupPose();
}
}
You can also find a list of references regarding the new Skin API and the Mix and Match
Spine project here posted by Nate: Combining Skins
Note that this does not include the repacking step (which is added in the code above), which is spine-unity specific.