Skip to content

Commit f3f9df9

Browse files
committed
Prevent packing textures bigger than sprite sheet size
1 parent a95221a commit f3f9df9

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

Assets/RuntimeSpriteSheetsGenerator/Scripts/AssetPacker/AssetPacker.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,17 @@ protected IEnumerator createPack(string savePath = "") {
8181
images.Add(itemToRaster.id);
8282
}
8383

84+
int textureSize = allow4096Textures ? 4096 : 2048;
85+
8486
List<Rect> rectangles = new List<Rect>();
8587
for (int i = 0; i < textures.Count; i++)
86-
rectangles.Add(new Rect(0, 0, textures[i].width, textures[i].height));
88+
if (textures[i].width > textureSize || textures[i].height > textureSize)
89+
throw new Exception("A texture size is bigger than the sprite sheet size!");
90+
else
91+
rectangles.Add(new Rect(0, 0, textures[i].width, textures[i].height));
8792

8893
const int padding = 1;
8994

90-
int textureSize = allow4096Textures ? 4096 : 2048;
91-
9295
int numSpriteSheet = 0;
9396
while (rectangles.Count > 0) {
9497

0 commit comments

Comments
 (0)