Technically slot color is separate from the skin, it is not reset if the skin is changed. I guess you are calling Skeleton setToSetupPose
or Skeleton setSlotsToSetupPose
when changing skins? Note while that is often what a user wants, it may not always be the case.
Setting the slot color will affect any attachment in that slot. The slot color may be keyed in animations, which would overwrite the set color when such an animation is applied. Because of this it is common to apply animations, then apply other changes (set slot color, change attachments, modify bone transforms, etc).
Setting the attachment color affects only that attachment. If the attachment is not copied, the color change may affect multiple skeleton instances using the same attachment instance. If the attachment is copied, code that attaches a specific attachment will attach the original attachment, where the color was not set. For example, an animation with an AttachmentTimeline uses Skeleton getAttachment
to find the attachment by name in the skeleton's active skins, as does Slot setToSetupPose
. Your code sets the attachment in the skin, which means if other skeleton instances use that skin instance, they could end up with the colored attachment if it is keyed in an animation or Slot setToSetupPose
(or Skeleton setToSetupPose
or Skeleton setSlotsToSetupPose
, which call Slot setToSetupPose
).
It may complicate your API to provide users with utility methods that copy an attachment and replace the old attachment in the skin. What is your end goal? If it's just to set an attachment's color, a method that does that (without copying it or changing the skins) could make sense if it is a common need and the manual way of doing it is verbose. If you want to provide a way to set a slot's color and have it override any existing color or that from animations, it could make sense to have a method that adds the color to a list for the skeleton and sets the slot colors every frame, after applying animations. You could do this with other things, too (any changes to skeleton/slot/bone/etc state: setting attachments, bone transforms, etc).