com.wallstop-studios.unity-helpers 2.0.0-rc74.7 → 2.0.0-rc74.9

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 -= _leftPadding;
367
- minY -= _bottomPadding;
368
- maxX += _rightPadding;
369
- 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,21 +391,32 @@
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
- int sourceIndex = sourceYOffset + x + minX;
392
- Color32 sourcePixel;
393
- if (sourceIndex < 0 || pixels.Length <= sourceIndex)
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 (
407
+ insideOriginal
408
+ && 0 <= srcX
409
+ && srcX < width
410
+ && 0 <= srcY
411
+ && srcY < height
412
+ )
394
413
  {
395
- sourcePixel = Color.clear;
414
+ croppedPixels[destRow + x] = pixels[srcY * width + srcX];
396
415
  }
397
416
  else
398
417
  {
399
- sourcePixel = pixels[sourceIndex];
418
+ croppedPixels[destRow + x] = Color.clear;
400
419
  }
401
- croppedPixels[destYOffset + x] = sourcePixel;
402
420
  }
403
421
  }
404
422
  );
@@ -16,6 +16,22 @@
16
16
 
17
17
  public static class SceneHelper
18
18
  {
19
+ public static bool IsSceneLoaded(string sceneNameOrPath)
20
+ {
21
+ for (int i = 0; i < SceneManager.sceneCount; ++i)
22
+ {
23
+ Scene scene = SceneManager.GetSceneAt(i);
24
+ if (
25
+ string.Equals(scene.name, sceneNameOrPath, StringComparison.Ordinal)
26
+ || string.Equals(scene.path, sceneNameOrPath, StringComparison.Ordinal)
27
+ )
28
+ {
29
+ return true;
30
+ }
31
+ }
32
+ return false;
33
+ }
34
+
19
35
  public static string[] GetAllScenePaths(string[] searchFolders = null)
20
36
  {
21
37
  #if UNITY_EDITOR
@@ -68,11 +84,10 @@
68
84
  async () =>
69
85
  {
70
86
  TaskCompletionSource<bool> disposalComplete = new();
71
- UnityMainThreadDispatcher.Instance.RunOnMainThread(
72
- () =>
73
- _ = sceneScope
74
- .DisposeAsync()
75
- .WithContinuation(() => disposalComplete.SetResult(true))
87
+ UnityMainThreadDispatcher.Instance.RunOnMainThread(() =>
88
+ _ = sceneScope
89
+ .DisposeAsync()
90
+ .WithContinuation(() => disposalComplete.SetResult(true))
76
91
  );
77
92
 
78
93
  await disposalComplete.Task;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "com.wallstop-studios.unity-helpers",
3
- "version": "2.0.0-rc74.7",
3
+ "version": "2.0.0-rc74.9",
4
4
  "displayName": "Unity Helpers",
5
5
  "description": "Various Unity Helper Library",
6
6
  "dependencies": {},
@@ -60,6 +60,8 @@
60
60
 
61
61
 
62
62
 
63
+
64
+
63
65
 
64
66
 
65
67