com.wallstop-studios.unity-helpers 2.0.0-rc73.12 → 2.0.0-rc73.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Editor/SpriteCropper.cs +9 -8
- package/package.json +3 -1
package/Editor/SpriteCropper.cs
CHANGED
|
@@ -302,9 +302,7 @@
|
|
|
302
302
|
int maxX = 0;
|
|
303
303
|
int maxY = 0;
|
|
304
304
|
bool hasVisible = false;
|
|
305
|
-
|
|
306
305
|
object lockObject = new();
|
|
307
|
-
|
|
308
306
|
Parallel.For(
|
|
309
307
|
0,
|
|
310
308
|
width * height,
|
|
@@ -341,19 +339,22 @@
|
|
|
341
339
|
}
|
|
342
340
|
);
|
|
343
341
|
|
|
344
|
-
if (!hasVisible)
|
|
345
|
-
{
|
|
346
|
-
return null;
|
|
347
|
-
}
|
|
348
|
-
|
|
349
342
|
int cropWidth = maxX - minX + 1;
|
|
350
343
|
int cropHeight = maxY - minY + 1;
|
|
351
344
|
|
|
352
|
-
if (_onlyNecessary && cropWidth == width && cropHeight == height)
|
|
345
|
+
if (_onlyNecessary && (!hasVisible || (cropWidth == width && cropHeight == height)))
|
|
353
346
|
{
|
|
354
347
|
return null;
|
|
355
348
|
}
|
|
356
349
|
|
|
350
|
+
if (!hasVisible)
|
|
351
|
+
{
|
|
352
|
+
cropWidth = 1;
|
|
353
|
+
cropHeight = 1;
|
|
354
|
+
minX = 0;
|
|
355
|
+
minY = 0;
|
|
356
|
+
}
|
|
357
|
+
|
|
357
358
|
Texture2D cropped = new(cropWidth, cropHeight, TextureFormat.RGBA32, false);
|
|
358
359
|
Color32[] croppedPixels = new Color32[cropWidth * cropHeight];
|
|
359
360
|
|
package/package.json
CHANGED