From b0a19f30c4f691e7dd429d8050e622e07fc37fd6 Mon Sep 17 00:00:00 2001 From: pharan Date: Wed, 1 Aug 2018 17:15:03 +0800 Subject: [PATCH] [unity] Remove old Texture.Apply calls. This is a breaking change to the AtlasRegion.ToTexture API. But the callers only need to remove the applyImmediately arg for it to work correctly. --- .../AttachmentTools/AttachmentTools.cs | 21 +++++-------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Modules/AttachmentTools/AttachmentTools.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Modules/AttachmentTools/AttachmentTools.cs index ff9d3d858..9b3deeeca 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Modules/AttachmentTools/AttachmentTools.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Modules/AttachmentTools/AttachmentTools.cs @@ -273,7 +273,7 @@ namespace Spine.Unity.Modules.AttachmentTools { material.CopyPropertiesFromMaterial(materialPropertySource); material.shaderKeywords = materialPropertySource.shaderKeywords; } - var newTexture = t.GetClone(false, textureFormat, mipmaps); + var newTexture = t.GetClone(textureFormat, mipmaps); newTexture.ApplyPMA(true); newTexture.name = t.name + "-pma-"; @@ -331,7 +331,7 @@ namespace Spine.Unity.Modules.AttachmentTools { material.shaderKeywords = materialPropertySource.shaderKeywords; } - var tex = s.ToTexture(false, textureFormat, mipmaps); + var tex = s.ToTexture(textureFormat, mipmaps); tex.ApplyPMA(true); tex.name = s.name + "-pma-"; @@ -586,7 +586,7 @@ namespace Spine.Unity.Modules.AttachmentTools { /// Creates a new Texture2D object based on an AtlasRegion. /// If applyImmediately is true, Texture2D.Apply is called immediately after the Texture2D is filled with data. - public static Texture2D ToTexture (this AtlasRegion ar, bool applyImmediately = true, TextureFormat textureFormat = SpineTextureFormat, bool mipmaps = UseMipMaps) { + public static Texture2D ToTexture (this AtlasRegion ar, TextureFormat textureFormat = SpineTextureFormat, bool mipmaps = UseMipMaps) { Texture2D output; CachedRegionTextures.TryGetValue(ar, out output); @@ -599,33 +599,22 @@ namespace Spine.Unity.Modules.AttachmentTools { AtlasUtilities.CopyTexture(sourceTexture, r, output); CachedRegionTextures.Add(ar, output); CachedRegionTexturesList.Add(output); - - if (applyImmediately) - output.Apply(); } return output; } - static Texture2D ToTexture (this Sprite s, bool applyImmediately = true, TextureFormat textureFormat = SpineTextureFormat, bool mipmaps = UseMipMaps) { + static Texture2D ToTexture (this Sprite s, TextureFormat textureFormat = SpineTextureFormat, bool mipmaps = UseMipMaps) { var spriteTexture = s.texture; var r = s.textureRect; var newTexture = new Texture2D((int)r.width, (int)r.height, textureFormat, mipmaps); AtlasUtilities.CopyTexture(spriteTexture, r, newTexture); - - if (applyImmediately) - newTexture.Apply(); - return newTexture; } - static Texture2D GetClone (this Texture2D t, bool applyImmediately = true, TextureFormat textureFormat = SpineTextureFormat, bool mipmaps = UseMipMaps) { + static Texture2D GetClone (this Texture2D t, TextureFormat textureFormat = SpineTextureFormat, bool mipmaps = UseMipMaps) { var newTexture = new Texture2D((int)t.width, (int)t.height, textureFormat, mipmaps); AtlasUtilities.CopyTexture(t, new Rect(0, 0, t.width, t.height), newTexture); - - if (applyImmediately) - newTexture.Apply(); - return newTexture; }