Please refer to Mix and Match Skins
as Harald told you:
Select "Character (mix-and-match-pro)" GameObject to find the example script MixAndMatchSkinsExample.cs
. As shown in the example script, not only the skin that has been changed, but also the skins that were already set up need to be added into the new skin to update the combination. For example, in your case, you would need the following code:
public class CombineSkins : MonoBehaviour
{
[SpineSkin] public string hat = "";
[SpineSkin] public string eyeglasses = "";
SkeletonAnimation skeletonAnimation;
void Awake () {
skeletonAnimation = this.GetComponent<SkeletonAnimation>();
}
public void Ace(){
hat = "HatAce";
UpdateSkin();
}
public void Circle(){
eyeglasses = "EyeglassesCircle";
UpdateSkin();
}
void UpdateSkin () {
var skeleton = skeletonAnimation.Skeleton;
var skeletonData = skeleton.Data;
var characterSkin = new Skin("character");
if (!string.IsNullOrEmpty(hat)) characterSkin.AddSkin(skeletonData.FindSkin(hat));
if (!string.IsNullOrEmpty(eyeglasses)) characterSkin.AddSkin(skeletonData.FindSkin(eyeglasses));
skeleton.SetSkin(characterSkin);
skeleton.SetSlotsToSetupPose();
}
}
The above code does only the bare minimum. In practice, it is better to repack the atlas textures with just the used attachments as in the MixAndMatchSkinsExample.cs
, and note that it is written for clarity anyway. I am not very familiar with C#, so Harald may add more information later.