- Modifié
Getting all the slots from a skin so I can change their RGB
I had this great idea that instead of creating different clothing of different colors manually, it would be easier to change the color of a shirt, for example, at runtime by changing the RGB values of the slots there. Trust me, this is better for my purposes than creating separate art assets manually.
I can get a slot and I can change its color:
Slot hatSlot = skeleton.FindSlot("hat");
hatSlot.R = 217f/255f;
hatSlot.G = 89f / 255f;
hatSlot.B = 89f / 255f;
But I can't figure out how to get all the slots that are associated with a skin. For example, I have a skins for "Top" and they encompass slots: shirt, R_upper_arm, R_lower_arm, L_upper_arm, L_lower_arm, torso, and chest.
So if I wanted to make the "Top" skin a red color, it would automatically apply a certain RGB value to all those aforementioned slots. Make sense?
I'm using the XNA runtime.
You can iterate all entries in the skin via Skin.Attachments
:
https://github.com/EsotericSoftware/spine-runtimes/blob/4.0/spine-csharp/src/Skin.cs#L50
Each SkinEntry also stores the slot index the attachment belongs to, which you can use to find the slot and set its color.
Thanks. I did something like this and it works.
foreach(Skin.SkinEntry s in foundSkin.Attachments)
{
skeleton.Slots.Items[s.SlotIndex].R = 0.25f;
}