From 9ecf28b2530e79838aab1817393d3a08d6c5dcf6 Mon Sep 17 00:00:00 2001 From: Harald Csaszar Date: Thu, 9 Dec 2021 18:34:24 +0100 Subject: [PATCH] [Unity] Fixed Sprite Mesh Type 'Tight' causing issues when used to replace attachments (GetRemappedClone, ToAtlasRegion). Closes #1884. Closes pull request #1994. --- .../Runtime/spine-unity/Utility/AtlasUtilities.cs | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) 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 e1d6fe66e..d284d8b13 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Utility/AtlasUtilities.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Utility/AtlasUtilities.cs @@ -193,18 +193,15 @@ namespace Spine.Unity.AttachmentTools { region.index = -1; region.degrees = s.packed && s.packingRotation != SpritePackingRotation.None ? 90 : 0; - // World space units - Bounds bounds = s.bounds; - Vector2 boundsMin = bounds.min, boundsMax = bounds.max; - // Texture space/pixel units - Rect spineRect = s.rect.SpineUnityFlipRect(s.texture.height); + Rect spineRect = s.textureRect.SpineUnityFlipRect(s.texture.height); + Rect originalRect = s.rect; region.width = (int)spineRect.width; - region.originalWidth = (int)spineRect.width; + region.originalWidth = (int)originalRect.width; region.height = (int)spineRect.height; - region.originalHeight = (int)spineRect.height; - region.offsetX = spineRect.width * (0.5f - InverseLerp(boundsMin.x, boundsMax.x, 0)); - region.offsetY = spineRect.height * (0.5f - InverseLerp(boundsMin.y, boundsMax.y, 0)); + region.originalHeight = (int)originalRect.height; + region.offsetX = s.textureRectOffset.x; + region.offsetY = s.textureRectOffset.y; if (isolatedTexture) { region.u = 0;