From 06a18da27be7a24f5583eb5c1c3ae16563200e5a Mon Sep 17 00:00:00 2001 From: John Date: Tue, 31 Oct 2017 21:07:09 +0800 Subject: [PATCH] [unity] Fix Repacking caching. --- .../Modules/AttachmentTools/AttachmentTools.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/spine-unity/Assets/spine-unity/Modules/AttachmentTools/AttachmentTools.cs b/spine-unity/Assets/spine-unity/Modules/AttachmentTools/AttachmentTools.cs index a989a9203..6a7934333 100644 --- a/spine-unity/Assets/spine-unity/Modules/AttachmentTools/AttachmentTools.cs +++ b/spine-unity/Assets/spine-unity/Modules/AttachmentTools/AttachmentTools.cs @@ -399,7 +399,7 @@ namespace Spine.Unity.Modules.AttachmentTools { /// The List(Attachment) to populate with the newly created Attachment objects. /// /// May be null. If no Material property source is provided, no special - public static void GetRepackedAttachments (List sourceAttachments, List outputAttachments, Material materialPropertySource, out Material outputMaterial, out Texture2D outputTexture, int maxAtlasSize = 1024, int padding = 2, TextureFormat textureFormat = SpineTextureFormat, bool mipmaps = UseMipMaps, string newAssetName = "Repacked Attachments") { + public static void GetRepackedAttachments (List sourceAttachments, List outputAttachments, Material materialPropertySource, out Material outputMaterial, out Texture2D outputTexture, int maxAtlasSize = 1024, int padding = 2, TextureFormat textureFormat = SpineTextureFormat, bool mipmaps = UseMipMaps, string newAssetName = "Repacked Attachments", bool clearCache = false) { if (sourceAttachments == null) throw new System.ArgumentNullException("sourceAttachments"); if (outputAttachments == null) throw new System.ArgumentNullException("outputAttachments"); @@ -468,8 +468,8 @@ namespace Spine.Unity.Modules.AttachmentTools { } // Clean up. - foreach (var ttp in texturesToPack) - UnityEngine.Object.Destroy(ttp); + if (clearCache) + AtlasUtilities.ClearCache(); outputTexture = newTexture; outputMaterial = newMaterial; @@ -485,7 +485,7 @@ namespace Spine.Unity.Modules.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. /// No Spine.Atlas object is created so there is no way to find AtlasRegions except through the Attachments using them. - 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) { + 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) { var skinAttachments = o.Attachments; var newSkin = new Skin(newName); @@ -553,8 +553,8 @@ namespace Spine.Unity.Modules.AttachmentTools { } // Clean up. - foreach (var ttp in texturesToPack) - UnityEngine.Object.Destroy(ttp); + if (clearCache) + AtlasUtilities.ClearCache(); outputTexture = newTexture; outputMaterial = newMaterial;