diff --git a/spine-unity/Assets/Spine Examples/Scripts/Mix and Match Character Customize/EquipsVisualsComponentExample.cs b/spine-unity/Assets/Spine Examples/Scripts/Mix and Match Character Customize/EquipsVisualsComponentExample.cs
index 5b76e9f3c..a548a3408 100644
--- a/spine-unity/Assets/Spine Examples/Scripts/Mix and Match Character Customize/EquipsVisualsComponentExample.cs
+++ b/spine-unity/Assets/Spine Examples/Scripts/Mix and Match Character Customize/EquipsVisualsComponentExample.cs
@@ -73,6 +73,11 @@ namespace Spine.Unity.Examples {
collectedSkin.AddAttachments(equipsSkin);
// 2. Create a repacked skin.
+ // Note: materials and textures returned by GetRepackedSkin() behave like 'new Texture2D()' and need to be destroyed
+ if (runtimeMaterial)
+ Destroy(runtimeMaterial);
+ if (runtimeAtlas)
+ Destroy(runtimeAtlas);
var repackedSkin = collectedSkin.GetRepackedSkin("Repacked skin", skeletonAnimation.SkeletonDataAsset.atlasAssets[0].PrimaryMaterial, out runtimeMaterial, out runtimeAtlas);
collectedSkin.Clear();
diff --git a/spine-unity/Assets/Spine Examples/Scripts/MixAndMatch.cs b/spine-unity/Assets/Spine Examples/Scripts/MixAndMatch.cs
index 696c22b79..bea5f22e9 100644
--- a/spine-unity/Assets/Spine Examples/Scripts/MixAndMatch.cs
+++ b/spine-unity/Assets/Spine Examples/Scripts/MixAndMatch.cs
@@ -121,6 +121,11 @@ namespace Spine.Unity.Examples {
var repackedSkin = new Skin("repacked skin");
repackedSkin.AddAttachments(skeleton.Data.DefaultSkin); // Include the "default" skin. (everything outside of skin placeholders)
repackedSkin.AddAttachments(customSkin); // Include your new custom skin.
+ // Note: materials and textures returned by GetRepackedSkin() behave like 'new Texture2D()' and need to be destroyed
+ if (runtimeMaterial)
+ Destroy(runtimeMaterial);
+ if (runtimeAtlas)
+ Destroy(runtimeAtlas);
repackedSkin = repackedSkin.GetRepackedSkin("repacked skin", sourceMaterial, out runtimeMaterial, out runtimeAtlas); // Pack all the items in the skin.
skeleton.SetSkin(repackedSkin); // Assign the repacked skin to your Skeleton.
if (bbFollower != null) bbFollower.Initialize(true);
diff --git a/spine-unity/Assets/Spine Examples/Scripts/MixAndMatchGraphic.cs b/spine-unity/Assets/Spine Examples/Scripts/MixAndMatchGraphic.cs
index ed2e80ad9..570abd4d0 100644
--- a/spine-unity/Assets/Spine Examples/Scripts/MixAndMatchGraphic.cs
+++ b/spine-unity/Assets/Spine Examples/Scripts/MixAndMatchGraphic.cs
@@ -119,6 +119,11 @@ namespace Spine.Unity.Examples {
var repackedSkin = new Skin("repacked skin");
repackedSkin.AddAttachments(skeleton.Data.DefaultSkin);
repackedSkin.AddAttachments(customSkin);
+ // Note: materials and textures returned by GetRepackedSkin() behave like 'new Texture2D()' and need to be destroyed
+ if (runtimeMaterial)
+ Destroy(runtimeMaterial);
+ if (runtimeAtlas)
+ Destroy(runtimeAtlas);
repackedSkin = repackedSkin.GetRepackedSkin("repacked skin", sourceMaterial, out runtimeMaterial, out runtimeAtlas);
skeleton.SetSkin(repackedSkin);
} else {
diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Utility/AtlasUtilities.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Utility/AtlasUtilities.cs
index d65480ff9..ce0a60ebd 100644
--- a/spine-unity/Assets/Spine/Runtime/spine-unity/Utility/AtlasUtilities.cs
+++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Utility/AtlasUtilities.cs
@@ -217,7 +217,10 @@ namespace Spine.Unity.AttachmentTools {
#region Runtime Repacking
///
- /// Fills the outputAttachments list with new attachment objects based on the attachments in sourceAttachments, but mapped to a new single texture using the same material.
+ /// Fills the outputAttachments list with new attachment objects based on the attachments in sourceAttachments,
+ /// but mapped to a new single texture using the same material.
+ /// Returned Material and Texture behave like new Texture2D(), thus you need to call Destroy()
+ /// to free resources.
/// The list of attachments to be repacked.
/// The List(Attachment) to populate with the newly created Attachment objects.
///
@@ -310,7 +313,9 @@ namespace Spine.Unity.AttachmentTools {
/// Creates and populates a duplicate skin with cloned attachments that are backed by a new packed texture atlas
/// comprised of all the regions from the original skin.
/// GetRepackedSkin is an expensive operation, preferably call it at level load time.
- /// No Spine.Atlas object is created so there is no way to find AtlasRegions except through the Attachments using them.
+ /// No Spine.Atlas object is created so there is no way to find AtlasRegions except through the Attachments using them.
+ /// Returned Material and Texture behave like new Texture2D(), thus you need to call Destroy()
+ /// to free resources.
/// Optional additional textures (such as normal maps) to copy while repacking.
/// To copy e.g. the main texture and normal maps, pass 'new int[] { Shader.PropertyToID("_BumpMap") }' at this parameter.
/// When additionalTexturePropertyIDsToCopy is non-null,
@@ -342,7 +347,9 @@ namespace Spine.Unity.AttachmentTools {
/// Creates and populates a duplicate skin with cloned attachments that are backed by a new packed texture atlas
/// comprised of all the regions from the original skin.
/// GetRepackedSkin is an expensive operation, preferably call it at level load time.
- /// No Spine.Atlas object is created so there is no way to find AtlasRegions except through the Attachments using them.
+ /// No Spine.Atlas object is created so there is no way to find AtlasRegions except through the Attachments using them.
+ /// Returned Material and Texture behave like new Texture2D(), thus you need to call Destroy()
+ /// to free resources.
public static Skin GetRepackedSkin (this Skin o, string newName, Shader shader, out Material outputMaterial, out Texture2D outputTexture,
int maxAtlasSize = 1024, int padding = 2, TextureFormat textureFormat = SpineTextureFormat, bool mipmaps = UseMipMaps,
Material materialPropertySource = null, bool clearCache = false, bool useOriginalNonrenderables = true,