@AmazeFPig Good point! In order to free the Texture
and Material
of the returned Attachment
, you would need to call something like this (in the EquipSystemExample.cs
script for example):
foreach (IHasTextureRegion attachment in cachedAttachments.Values) {
Material material = (Material)((AtlasRegion)attachment.Region).page.rendererObject;
Destroy(material.mainTexture);
Destroy(material);
}
cachedAttachments.Clear();
Just note that in the Mix and Match Equip
example scene, the equip logic is not well suited for deleting the remapped attachment's material and texture and then e.g. hitting Done
twice, since the logic relies on always creating the skin via
collectedSkin.Clear();
collectedSkin.AddSkin(skeletonAnimation.Skeleton.Data.DefaultSkin);
collectedSkin.AddSkin(equipsSkin);
where equipsSkin
would then still need either the un-deleted attachment with the PMA material and texture, or have equipsSkin
re-created again. Mentioning this just in case you wonder why hitting Done
twice without changing the selected attachment then leads to an exception.
By the way: The GetRemappedClone
methods will be replaced in the near future (in this issue ticket) with better suitable Attachment.SetRegion(Sprite sprite)
methods.