It seems like you are encountering an issue where changing from one skin to another with similar names doesn't work as expected. Based on the provided contexts, here are a few things to consider:
Default Skin Behavior: The default skin holds all items not in a skin in the editor. If you are switching from a skin to the default skin and it works, it might be because the default skin is handling attachments differently. Ensure that the attachments in both skins are correctly set up and named.
Skin Attachments: When switching skins, ensure that the attachments are correctly referenced. If the attachments in the new skin are not being set, it might be due to a naming issue or the way the attachments are being referenced. You can check the runtime skins documentation for more details on setting individual attachments programmatically: Runtime Skins - Spine Runtimes Guide: Creating attachments.
Set Slots to Setup Pose: After setting a new skin, you might need to call skeleton.SetSlotsToSetupPose()
to ensure that the slots are updated to the new skin's attachments. This is a common step to ensure that the new skin's attachments are correctly applied.
Skin Placeholder Names: Ensure that the skin placeholder names are consistent and correctly referenced in both skins. Any discrepancy in naming can cause issues when switching skins.
Here is a sample code snippet to ensure that the skin is set correctly and the slots are updated:
void ChangeSkin(string newSkinName) {
Skeleton skeleton = GetComponent<SkeletonAnimation>().Skeleton;
Skin newSkin = skeleton.Data.FindSkin(newSkinName);
if (newSkin != null) {
skeleton.SetSkin(newSkin);
skeleton.SetSlotsToSetupPose();
} else {
Debug.LogError("Skin not found: " + newSkinName);
}
}
Make sure to replace newSkinName
with the name of the skin you want to switch to, such as "football-helmet" or "football".
If the issue persists, it might be helpful to debug and check if the skin names are being correctly referenced and if the attachments are correctly set in both skins.