com.wallstop-studios.unity-helpers 2.0.0-rc74.6 → 2.0.0-rc74.8

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.
@@ -352,25 +352,32 @@
352
352
  }
353
353
  );
354
354
 
355
- int cropWidth;
356
- int cropHeight;
357
- if (!hasVisible)
355
+ int origMinX = minX;
356
+ int origMinY = minY;
357
+ int origMaxX = maxX;
358
+ int origMaxY = maxY;
359
+
360
+ int visibleMinX = minX;
361
+ int visibleMinY = minY;
362
+ int visibleMaxX = maxX;
363
+ int visibleMaxY = maxY;
364
+
365
+ if (hasVisible)
358
366
  {
359
- cropWidth = 1;
360
- cropHeight = 1;
361
- minX = 0;
362
- minY = 0;
367
+ visibleMinX -= _leftPadding;
368
+ visibleMinY -= _bottomPadding;
369
+ visibleMaxX += _rightPadding;
370
+ visibleMaxY += _topPadding;
363
371
  }
364
372
  else
365
373
  {
366
- minX = Mathf.Max(0, minX - _leftPadding);
367
- minY = Mathf.Max(0, minY - _bottomPadding);
368
- maxX = Mathf.Min(width, maxX + _rightPadding);
369
- maxY = Mathf.Min(height, maxY + _topPadding);
370
- cropWidth = maxX - minX + 1;
371
- cropHeight = maxY - minY + 1;
374
+ visibleMinX = visibleMinY = 0;
375
+ visibleMaxX = visibleMaxY = 0;
372
376
  }
373
377
 
378
+ int cropWidth = visibleMaxX - visibleMinX + 1;
379
+ int cropHeight = visibleMaxY - visibleMinY + 1;
380
+
374
381
  if (_onlyNecessary && (!hasVisible || (cropWidth == width && cropHeight == height)))
375
382
  {
376
383
  return null;
@@ -384,11 +391,33 @@
384
391
  cropHeight,
385
392
  y =>
386
393
  {
387
- int sourceYOffset = (y + minY) * width;
388
- int destYOffset = y * cropWidth;
394
+ int destRow = y * cropWidth;
389
395
  for (int x = 0; x < cropWidth; ++x)
390
396
  {
391
- croppedPixels[destYOffset + x] = pixels[sourceYOffset + x + minX];
397
+ int srcX = visibleMinX + x;
398
+ int srcY = visibleMinY + y;
399
+
400
+ bool insideOriginal =
401
+ srcX >= origMinX
402
+ && srcX <= origMaxX
403
+ && srcY >= origMinY
404
+ && srcY <= origMaxY;
405
+
406
+ if (insideOriginal)
407
+ {
408
+ if (0 <= srcX && srcX < width && 0 <= srcY && srcY < height)
409
+ {
410
+ croppedPixels[destRow + x] = pixels[srcY * width + srcX];
411
+ }
412
+ else
413
+ {
414
+ croppedPixels[destRow + x] = Color.clear;
415
+ }
416
+ }
417
+ else
418
+ {
419
+ croppedPixels[destRow + x] = Color.clear;
420
+ }
392
421
  }
393
422
  }
394
423
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "com.wallstop-studios.unity-helpers",
3
- "version": "2.0.0-rc74.6",
3
+ "version": "2.0.0-rc74.8",
4
4
  "displayName": "Unity Helpers",
5
5
  "description": "Various Unity Helper Library",
6
6
  "dependencies": {},
@@ -59,6 +59,8 @@
59
59
 
60
60
 
61
61
 
62
+
63
+
62
64
 
63
65
 
64
66