- Modifié
How refresh character after SetSkin()
- I have a character with two skins. The second skin has a character with a huge hammer.
- I change the skin with Spine.Skeleton.SetSkin( "huge_hammer" ).
- But the skin is not visible until I play an animation that has data for the huge hammer.
Is there a for me to force character to update so that shows the correct skin?
Best, Hu
Unity 5.6.2f1
Spine runtime 3.5.xx
You can call Skeleton setSlotsToSetupPose
after changing the skin. This will show the attachments that are visible in setup mode. If you want different attachments visible, you'll have to call Skeleton setAttachment
for each one you want visible.
You likely want:
skeletonAnimation.Skeleton.SetSkin("huge_hammer"); // set the skin
skeletonAnimation.Skeleton.SetSlotsToSetupPose(); // use the active attachments from setup pose.
skeletonAnimation.AnimationState.Apply(skeleton); // use the active attachments from the active animations.
Thanks, that did the trick.
Best, Hu
I ran into this issue today, and had to use SetSlotsToSetupPose() as well, but just curious about something.
I was working on a project just about a month ago, and I didn't have to use SetSlotsToSetupPose() after setting the skin. It updated on it's own. Just wondering if something changed in the backend, or I was lucky, or there is something that I can do in the skeleton set up to avoid having to call SetSlotsToSetupPose().
Thanks!
Maybe your attachments were already visible in the old skin? See here:
Runtime Skins - Spine Runtimes Guide: Skin changes
Hmm... That is a possibility. One of the skins in my new project, has no image in the placeholder (which makes me think I should change to swapping slot visibility instead of skins), so maybe that's why?
How heavy is the overhead of the SetSlotsToSetupPose() method?
See the source, it is very simple. For each slot it does a getAttachment
call to find an attachment in the skin. This is very cheap.
Alrighty! Thanks for the help!
Cheers!