Skip to content

Commit

Permalink
Texture export fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Albeoris committed Feb 14, 2022
1 parent f909472 commit 392a66b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Memoria.FF1/Shared/BeepInEx/ExtensionMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ public static Vector2Int[] GetPixelVertices(this Sprite sprite)

Rect spriteRect = sprite.rect;
Rect textureRect = sprite.GetTextureRect();
RectInt pixelTextureRect = sprite.GetPixelTextureRect();
Single scaleX = textureRect.width / spriteRect.width;
Single scaleY = textureRect.height / spriteRect.height;
Vector2 pixelPivot = sprite.pivot;
Expand All @@ -164,8 +165,8 @@ public static Vector2Int[] GetPixelVertices(this Sprite sprite)
Single floatY = (mesh.y + pixelPivot.y) * scaleY - 0.01f;
Vector2Int pixel = new Vector2Int((Int32)Math.Round(floatX), (Int32)Math.Round(floatY));

if (pixel.x < 0 || pixel.y < 0 || pixel.x > textureRect.width || pixel.y > textureRect.height)
throw new NotSupportedException($"During transformation the coordinate of the {i} vertex of the sprite, the coordinate went beyond the boundaries of the sprite. Rect: {spriteRect}, TransformedVertex: ({floatX}, {floatY}), BeforeTransform: {mesh}");
if (pixel.x < 0 || pixel.y < 0 || pixel.x > pixelTextureRect.width || pixel.y > pixelTextureRect.height)
throw new NotSupportedException($"During transformation the coordinate of the {i} vertex of the sprite, the coordinate went beyond the boundaries of the sprite. SpriteRect: {spriteRect}, TextureRect: {textureRect}, Pivot: {pixelPivot} TransformedVertex: ({floatX}, {floatY}), BeforeTransform: {mesh}");

pixelVertices[i] = pixel;
}
Expand Down

0 comments on commit 392a66b

Please sign in to comment.