• Editor
  • Conditional Skins?

I've been wrestling with skins and I'm wondering if there's an easier way to do this that I'm blind to.

I was wondering if there's a way to do some kind of conditional skin selection? For example, if Skin 1 is selected, then Skin A will use a style that suits Skin 1. Or even if skins could be children of other skins.

A more in depth explanation:
We want to mix and match skins and accessories (much like the mix and match example) but have a subset of skins that are suitable for the overall style. So changing the "main" skin will drastically change the character appearance, then there would be a "sub" skin, which could be an accessory. That "sub skin" would then be styled according to the main skin.

The reason I'm looking to do this is so it's easier from a programming point of view. So the programmer can select Main Skin 1, with accessory A. For example, a male character with a bag. Then if they want Skin 2 with accessory A it could be female with a different bag. But Accessory A is always a bag, just styled differently for the main skin.

Does that make sense? The current mix and match example has the same bag regardless of character. Is that even possible? Am I over complicating it?? Thank you in advance!

Related Discussions
...

Yes, it is possible to achieve conditional skin selection in Spine, and it can be done programmatically to simplify the process for the programmer. Here’s how you can approach it:

  1. Create Separate Skins for Each Style: Create separate skins for each main style and accessory combination. For example, you can have MainSkin1_Bag, MainSkin2_Bag, etc. This way, each accessory is styled according to the main skin.

  2. Combine Skins at Runtime: Use the Spine runtime to combine these skins programmatically. You can create a base skin for the main character and then add the appropriate accessory skin based on the selected main skin.

  3. Use Skin Placeholders: Utilize skin placeholders to manage different attachments for each accessory. This allows you to switch between different styles of the same accessory without creating a new skin for each combination.

Here’s a simplified example of how you might implement this in code:

// Assuming you have a method to get the appropriate accessory skin based on the main skin
string GetAccessorySkin(string mainSkin, string accessory) {
    if (mainSkin == "MainSkin1") {
        return "MainSkin1_" + accessory;
    } else if (mainSkin == "MainSkin2") {
        return "MainSkin2_" + accessory;
    }
    return accessory; // Default accessory if no specific style is needed
}

// Example usage
string mainSkin = "MainSkin1";
string accessory = "Bag";
string accessorySkin = GetAccessorySkin(mainSkin, accessory);

// Combine the main skin and the accessory skin
Skin combinedSkin = new Skin("combined");
combinedSkin.AddSkin(skeletonData.FindSkin(mainSkin));
combinedSkin.AddSkin(skeletonData.FindSkin(accessorySkin));

// Apply the combined skin to the skeleton
skeleton.SetSkin(combinedSkin);
skeleton.SetSlotsToSetupPose();

This approach allows you to dynamically select and combine skins based on the main skin and accessory, ensuring that the accessory is styled appropriately for the main skin.

For more detailed examples and explanations, you can refer to the Mix and Match example and the Spine Runtimes Guide.

So what you want is a variation of a skin depending on the skin that is active, the only thing that comes to my mind that can achieve this is a skin constraint placed on the skin that modifies another skin's placement so it matches its proportions.
With the example of the bag, if you want the bag to be equipped differently if used by the boy, then you'd give the boy a transform constraint (or more) that repositions/resizes the bag bones.
Examples can be seen in the last chapters of this skins video:

Thanks Erika! The constraints were my starting point which worked to a degree, but we wanted something a bit more complex than they could offer. Definitely useful for other aspects though, so thank you for the video!

In the end we've opted for a more complex skin setup, with multiple skins with more artwork for each skin. Thanks!