Yes, it is possible to achieve the desired effect using Spine's skin functionality. You can create a base skin for each shading variation (SkinA, SkinB) and then combine these with the existing skins (Skin1, Skin2, Skin3) at runtime. This way, you can dynamically switch between different shading variations without affecting which skins are shown.
Here’s how you can do it:
Create Base Skins for Shading Variations: Create SkinA and SkinB, which contain the shading variations for all the attachments in Skin1, Skin2, and Skin3.
Combine Skins at Runtime: Use the addSkin()
method to combine the base skin (SkinA or SkinB) with the currently active skins (Skin1, Skin2, Skin3). This will allow you to apply the shading variation to the active skins.
Here is a basic example of how you can achieve this in code:
// Assuming you have a reference to your skeleton and skins
Skeleton skeleton = ...;
Skin skin1 = skeleton.data.findSkin("Skin1");
Skin skin2 = skeleton.data.findSkin("Skin2");
Skin skinA = skeleton.data.findSkin("SkinA");
Skin skinB = skeleton.data.findSkin("SkinB");
// Create a new skin to combine the active skins with the shading variation
Skin combinedSkin = new Skin("combinedSkin");
// Add the active skins
combinedSkin.addSkin(skin1);
combinedSkin.addSkin(skin2);
// Add the shading variation
combinedSkin.addSkin(skinA); // or skinB
// Set the combined skin to the skeleton
skeleton.setSkin(combinedSkin);
skeleton.setSlotsToSetupPose();
This approach allows you to dynamically switch between different shading variations while keeping the flexibility to toggle individual skins on or off.
For more detailed information, you can refer to the Spine Runtime Skins documentation and the Skins view in the Spine editor.