Harald yazdıgiangnb yazdıDid I do something wrong?
Yes, you posted a screenshot of your code instead of pasting it as
[code]text
[/code]
😉 But your syntax highlighting is nice, so it makes up for that. 8)
Joking aside: In case the SetSkin()
line at the bottom of your screenshot is the last one, please add the following code to update the attachments:
skeletonGraphic.Skeleton.SetSlotsToSetupPose();
skeletonGraphic.AnimationState.Apply(skeletonGraphic.Skeleton);
private void SetSkin(int outfitIdx = 0, int weaponIdx = 0, int idSkin = -1)
{
skeletonGraphic.initialSkinName = null;
skeletonGraphic.Initialize(true);
if (idSkin == -1)
{
var data = skeletonGraphic.skeletonDataAsset.GetSkeletonData(false);
Skin mySkin = new Skin("Custom Skin");
//Skin baseSkin = data.FindSkin("skin_base");
Skin outfitSkin = data.FindSkin("outfit/outfit_" + outfitIdx);
string weaponName = "sword";
switch (heroID)
{
case 0:
weaponName = "sword";
break;
case 1:
weaponName = "bow";
break;
case 2:
weaponName = "gun";
break;
case 3:
weaponName = "weapon";
break;
case 4:
weaponName = "spear";
break;
default:
break;
}
Skin weaponSkin = data.FindSkin("weapon/" + weaponName + "_" + weaponIdx);
//mySkin.AddAttachments(baseSkin);
mySkin.AddAttachments(outfitSkin);
mySkin.AddAttachments(weaponSkin);
skeletonGraphic.Skeleton.SetSkin(mySkin);
}
else
{
skeletonGraphic.Skeleton.SetSkin(UtilityGame.GetFullSkinName(heroID, idSkin));
}
skeletonGraphic.Skeleton.SetSlotsToSetupPose();
skeletonGraphic.AnimationState.Apply(skeletonGraphic.Skeleton);
skeletonGraphic.Update(Time.deltaTime);
}
I am using Unity 2019.4.8 and Spine 3.8. And the export structure is like the image below, I tried the code you just put, but it doesn't work
I also couldn't find
Advanced - Multiple Canvas Renderers
at SkeletonGraphic on Inspector