pixilestudios

Hello, just wanted to make sure this is correct... we previously used skin utilities method:
currentCustomSkin = characterSkin.GetClone();
But since that is gone I am now doing it this way:
currentCustomSkin = new Spine.Skin(characterSkin.Name + " clone");
currentCustomSkin.CopySkin(characterSkin);
Is this the correct way to replace that older method? It appears to work so far but wanted to make sure I'm not missing anything. Thanks!

(this is used for skin building like mix & match)
User avatar
pixilestudios
  • Posts: 19

Harald

Not precisely, as CopySkin is not the counterpart of GetClone. GetClone previously performed a shallow copy:
///<summary> Gets a shallow copy of the skin. The cloned skin's attachments are shared with the original skin.</summary>
while CopySkin performs a deep copy:
///<summary>Adds all attachments from the specified skin to this skin. Attachments are deep copied.</summary>
The difference is that the attachments are deep-copied in the latter, while only the attachment references are copied in the first method.

The precise counterpart for GetClone() would be AddSkin() instead of CopySkin().
User avatar
Harald

Harri
  • Posts: 4459

pixilestudios

Ah okay I guess I'll try that... if both seem to work is it better to just do the shallower AddSkin since it would be better on performance?
User avatar
pixilestudios
  • Posts: 19

Harald

Sorry for the late reply.

In general yes, performing the shallow copy would be more resource-friendly.

If you are not modifying any of the attachment objects itself (which is rather unlikely), you can get away with the shallow copy. If you do modify any of the referenced attachments, note that the changes will carry over to your copied skin.
User avatar
Harald

Harri
  • Posts: 4459


Return to Unity