com.wallstop-studios.unity-helpers 2.0.0-rc73.19 → 2.0.0-rc73.3

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.
Files changed (54) hide show
  1. package/Editor/{Sprites/AnimationCopier.cs → AnimationCopier.cs} +209 -84
  2. package/Editor/{Sprites/AnimationCreator.cs → AnimationCreator.cs} +100 -29
  3. package/Editor/AnimationEventEditor.cs +23 -10
  4. package/Editor/CustomEditors/MatchColliderToSpriteEditor.cs +1 -1
  5. package/Editor/FitTextureSizeWindow.cs +53 -14
  6. package/Editor/PrefabChecker.cs +18 -11
  7. package/Editor/SpriteAtlasGenerator.cs +914 -0
  8. package/Editor/SpriteAtlasGenerator.cs.meta +3 -0
  9. package/Editor/{Sprites/SpriteCropper.cs → SpriteCropper.cs} +143 -172
  10. package/Editor/{Sprites/SpriteSettingsApplier.cs → SpriteSettingsApplier.cs} +77 -12
  11. package/Editor/{Sprites/TextureResizerWizard.cs → TextureResizerWizard.cs} +1 -1
  12. package/Editor/{Sprites/TextureSettingsApplier.cs → TextureSettingsApplier.cs} +1 -1
  13. package/Editor/Utils/DxReadOnlyPropertyDrawer.cs +1 -1
  14. package/Editor/Utils/GUIHorizontalScope.cs +20 -0
  15. package/Editor/Utils/GUIHorizontalScope.cs.meta +3 -0
  16. package/Runtime/Core/DataStructure/Circle.cs +1 -1
  17. package/Runtime/Core/DataStructure/QuadTree.cs +4 -4
  18. package/Runtime/Core/Extension/ColorExtensions.cs +5 -5
  19. package/Runtime/Core/Extension/IEnumerableExtensions.cs +1 -1
  20. package/Runtime/Core/Extension/UnityExtensions.cs +14 -14
  21. package/Runtime/Core/Helper/DirectoryHelper.cs +0 -64
  22. package/Runtime/Core/Helper/Helpers.cs +9 -9
  23. package/Runtime/Core/Helper/Logging/UnityLogTagFormatter.cs +8 -31
  24. package/Runtime/Core/Helper/Partials/ObjectHelpers.cs +4 -5
  25. package/Runtime/Core/Helper/PathHelper.cs +1 -2
  26. package/Runtime/Core/Random/DotNetRandom.cs +1 -1
  27. package/Runtime/Core/Random/SplitMix64.cs +1 -1
  28. package/Runtime/Core/Random/SquirrelRandom.cs +7 -7
  29. package/Runtime/Core/Random/ThreadLocalRandom.cs +1 -1
  30. package/Runtime/Core/Random/WyRandom.cs +1 -1
  31. package/Runtime/Tags/EffectHandler.cs +1 -1
  32. package/Runtime/UI/LayeredImage.cs +161 -309
  33. package/Runtime/Utils/AnimatorEnumStateMachine.cs +1 -1
  34. package/Runtime/Utils/SetTextureImportData.cs +1 -1
  35. package/Runtime/Utils/TextureScale.cs +4 -4
  36. package/Styles/Elements/Progress/MarchingAntsProgressBar.cs +20 -20
  37. package/package.json +1 -17
  38. package/Editor/CustomEditors/PersistentDirectoryGUI.cs +0 -796
  39. package/Editor/CustomEditors/PersistentDirectoryGUI.cs.meta +0 -3
  40. package/Editor/CustomEditors/SourceFolderEntryDrawer.cs +0 -275
  41. package/Editor/CustomEditors/SourceFolderEntryDrawer.cs.meta +0 -3
  42. package/Editor/PersistentDirectorySettings.cs +0 -248
  43. package/Editor/PersistentDirectorySettings.cs.meta +0 -3
  44. package/Editor/Sprites/ScriptableSpriteAtlas.cs +0 -95
  45. package/Editor/Sprites/ScriptableSpriteAtlas.cs.meta +0 -3
  46. package/Editor/Sprites/ScriptableSpriteAtlasEditor.cs +0 -930
  47. package/Editor/Sprites/ScriptableSpriteAtlasEditor.cs.meta +0 -3
  48. package/Editor/Sprites.meta +0 -3
  49. /package/Editor/{Sprites/AnimationCopier.cs.meta → AnimationCopier.cs.meta} +0 -0
  50. /package/Editor/{Sprites/AnimationCreator.cs.meta → AnimationCreator.cs.meta} +0 -0
  51. /package/Editor/{Sprites/SpriteCropper.cs.meta → SpriteCropper.cs.meta} +0 -0
  52. /package/Editor/{Sprites/SpriteSettingsApplier.cs.meta → SpriteSettingsApplier.cs.meta} +0 -0
  53. /package/Editor/{Sprites/TextureResizerWizard.cs.meta → TextureResizerWizard.cs.meta} +0 -0
  54. /package/Editor/{Sprites/TextureSettingsApplier.cs.meta → TextureSettingsApplier.cs.meta} +0 -0
@@ -534,14 +534,14 @@
534
534
  rgb.b > 0.04045 ? Mathf.Pow((rgb.b + 0.055f) / 1.055f, 2.4f) : rgb.b / 12.92f;
535
535
 
536
536
  double x = (r * 0.4124 + g * 0.3576 + b * 0.1805) / 0.95047;
537
- double y = r * 0.2126 + g * 0.7152 + b * 0.0722;
537
+ double y = (r * 0.2126 + g * 0.7152 + b * 0.0722);
538
538
  double z = (r * 0.0193 + g * 0.1192 + b * 0.9505) / 1.08883;
539
539
 
540
- x = x > 0.008856 ? Mathf.Pow((float)x, 1f / 3f) : 7.787 * x + 16f / 116f;
541
- y = y > 0.008856 ? Mathf.Pow((float)y, 1f / 3f) : 7.787 * y + 16f / 116f;
542
- z = z > 0.008856 ? Mathf.Pow((float)z, 1f / 3f) : 7.787 * z + 16f / 116f;
540
+ x = x > 0.008856 ? Mathf.Pow((float)x, 1f / 3f) : (7.787 * x) + 16f / 116f;
541
+ y = y > 0.008856 ? Mathf.Pow((float)y, 1f / 3f) : (7.787 * y) + 16f / 116f;
542
+ z = z > 0.008856 ? Mathf.Pow((float)z, 1f / 3f) : (7.787 * z) + 16f / 116f;
543
543
 
544
- return new LABColor(116 * y - 16, 500 * (x - y), 200 * (y - z));
544
+ return new LABColor((116 * y) - 16, 500 * (x - y), 200 * (y - z));
545
545
  }
546
546
 
547
547
  private static Color LABToRGB(double l, double a, double b)
@@ -78,7 +78,7 @@
78
78
 
79
79
  public static IEnumerable<IEnumerable<T>> Partition<T>(this IEnumerable<T> items, int size)
80
80
  {
81
- using IEnumerator<T> enumerator = items.GetEnumerator();
81
+ using var enumerator = items.GetEnumerator();
82
82
  bool hasNext = enumerator.MoveNext();
83
83
 
84
84
  IEnumerable<T> NextPartitionOf()
@@ -126,9 +126,9 @@
126
126
  xMin,
127
127
  yMin,
128
128
  zMin,
129
- xMax - xMin + 1,
130
- yMax - yMin + 1,
131
- zMax - zMin + 1
129
+ (xMax - xMin) + 1,
130
+ (yMax - yMin) + 1,
131
+ (zMax - zMin) + 1
132
132
  );
133
133
  }
134
134
 
@@ -160,9 +160,9 @@
160
160
  xMin,
161
161
  yMin,
162
162
  zMin,
163
- xMax - xMin + 1,
164
- yMax - yMin + 1,
165
- zMax - zMin + 1
163
+ (xMax - xMin) + 1,
164
+ (yMax - yMin) + 1,
165
+ (zMax - zMin) + 1
166
166
  );
167
167
  }
168
168
 
@@ -584,8 +584,8 @@
584
584
  public float LargestAngle(FastVector3Int point)
585
585
  {
586
586
  Vector2 worldPoint = _grid.CellToWorld(point);
587
- float angleFrom = Vector2.Angle(toWorld - fromWorld, worldPoint - fromWorld);
588
- float angleTo = Vector2.Angle(fromWorld - toWorld, worldPoint - toWorld);
587
+ float angleFrom = Vector2.Angle((toWorld - fromWorld), (worldPoint - fromWorld));
588
+ float angleTo = Vector2.Angle((fromWorld - toWorld), (worldPoint - toWorld));
589
589
  return Math.Max(angleFrom, angleTo);
590
590
  }
591
591
  }
@@ -1126,7 +1126,7 @@
1126
1126
  }
1127
1127
 
1128
1128
  if (
1129
- newVector.x < position.x == position.x <= oldVector.x
1129
+ (newVector.x < position.x) == (position.x <= oldVector.x)
1130
1130
  && (position.y - (long)lhs.y) * (rhs.x - lhs.x)
1131
1131
  < (rhs.y - (long)lhs.y) * (position.x - lhs.x)
1132
1132
  )
@@ -1274,7 +1274,7 @@
1274
1274
  yield break;
1275
1275
  }
1276
1276
 
1277
- scaleFactor *= 4 / 3f;
1277
+ scaleFactor *= (4 / 3f);
1278
1278
  }
1279
1279
  }
1280
1280
 
@@ -1416,8 +1416,8 @@
1416
1416
  float ty = v.y;
1417
1417
 
1418
1418
  Vector2 rotatedVector;
1419
- rotatedVector.x = cos * tx - sin * ty;
1420
- rotatedVector.y = sin * tx + cos * ty;
1419
+ rotatedVector.x = (cos * tx) - (sin * ty);
1420
+ rotatedVector.y = (sin * tx) + (cos * ty);
1421
1421
 
1422
1422
  return rotatedVector;
1423
1423
  }
@@ -1564,12 +1564,12 @@
1564
1564
 
1565
1565
  public static bool IsOnEdge2D(this FastVector3Int position, BoundsInt bounds)
1566
1566
  {
1567
- if (bounds.xMin == position.x || bounds.xMax - 1 == position.x)
1567
+ if (bounds.xMin == position.x || (bounds.xMax - 1) == position.x)
1568
1568
  {
1569
1569
  return bounds.yMin <= position.y && position.y < bounds.yMax;
1570
1570
  }
1571
1571
 
1572
- if (bounds.yMin == position.y || bounds.yMax - 1 == position.y)
1572
+ if (bounds.yMin == position.y || (bounds.yMax - 1) == position.y)
1573
1573
  {
1574
1574
  return bounds.xMin <= position.x && position.x < bounds.xMax;
1575
1575
  }
@@ -4,73 +4,9 @@
4
4
  using System.IO;
5
5
  using System.Runtime.CompilerServices;
6
6
  using UnityEngine;
7
- #if UNITY_EDITOR
8
- using UnityEditor;
9
- #endif
10
7
 
11
8
  public static class DirectoryHelper
12
9
  {
13
- public static void EnsureDirectoryExists(string relativeDirectoryPath)
14
- {
15
- if (string.IsNullOrWhiteSpace(relativeDirectoryPath))
16
- {
17
- return;
18
- }
19
-
20
- #if UNITY_EDITOR
21
- if (!relativeDirectoryPath.StartsWith("Assets/"))
22
- {
23
- if (relativeDirectoryPath.Equals("Assets", StringComparison.OrdinalIgnoreCase))
24
- {
25
- return;
26
- }
27
-
28
- Debug.LogError(
29
- $"Attempted to create directory outside of Assets: '{relativeDirectoryPath}'"
30
- );
31
- throw new ArgumentException(
32
- "Cannot create directories outside the Assets folder using AssetDatabase.",
33
- nameof(relativeDirectoryPath)
34
- );
35
- }
36
-
37
- if (AssetDatabase.IsValidFolder(relativeDirectoryPath))
38
- {
39
- return;
40
- }
41
-
42
- string parentPath = Path.GetDirectoryName(relativeDirectoryPath).SanitizePath();
43
- if (
44
- string.IsNullOrWhiteSpace(parentPath)
45
- || parentPath.Equals("Assets", StringComparison.OrdinalIgnoreCase)
46
- )
47
- {
48
- string folderNameToCreate = Path.GetFileName(relativeDirectoryPath);
49
- if (
50
- !string.IsNullOrWhiteSpace(folderNameToCreate)
51
- && !AssetDatabase.IsValidFolder(relativeDirectoryPath)
52
- )
53
- {
54
- AssetDatabase.CreateFolder("Assets", folderNameToCreate);
55
- }
56
- return;
57
- }
58
-
59
- EnsureDirectoryExists(parentPath);
60
- string currentFolderName = Path.GetFileName(relativeDirectoryPath);
61
- if (
62
- !string.IsNullOrWhiteSpace(currentFolderName)
63
- && !AssetDatabase.IsValidFolder(relativeDirectoryPath)
64
- )
65
- {
66
- AssetDatabase.CreateFolder(parentPath, currentFolderName);
67
- Debug.Log($"Created folder: {relativeDirectoryPath}");
68
- }
69
- #else
70
- Directory.CreateDirectory(relativeDirectoryPath);
71
- #endif
72
- }
73
-
74
10
  public static string GetCallerScriptDirectory([CallerFilePath] string sourceFilePath = "")
75
11
  {
76
12
  return string.IsNullOrWhiteSpace(sourceFilePath)
@@ -47,9 +47,9 @@
47
47
  }
48
48
 
49
49
  float a =
50
- targetVelocity.x * targetVelocity.x
51
- + targetVelocity.y * targetVelocity.y
52
- - projectileSpeed * projectileSpeed;
50
+ (targetVelocity.x * targetVelocity.x)
51
+ + (targetVelocity.y * targetVelocity.y)
52
+ - (projectileSpeed * projectileSpeed);
53
53
 
54
54
  float b =
55
55
  2
@@ -59,10 +59,10 @@
59
59
  );
60
60
 
61
61
  float c =
62
- (target.x - launchLocation.x) * (target.x - launchLocation.x)
63
- + (target.y - launchLocation.y) * (target.y - launchLocation.y);
62
+ ((target.x - launchLocation.x) * (target.x - launchLocation.x))
63
+ + ((target.y - launchLocation.y) * (target.y - launchLocation.y));
64
64
 
65
- float disc = b * b - 4 * a * c;
65
+ float disc = b * b - (4 * a * c);
66
66
  if (disc < 0)
67
67
  {
68
68
  return target;
@@ -72,8 +72,8 @@
72
72
  float t2 = (-1 * b - Mathf.Sqrt(disc)) / (2 * a);
73
73
  float t = Mathf.Max(t1, t2); // let us take the larger time value
74
74
 
75
- float aimX = target.x + targetVelocity.x * t;
76
- float aimY = target.y + targetVelocity.y * t;
75
+ float aimX = target.x + (targetVelocity.x * t);
76
+ float aimY = target.y + (targetVelocity.y * t);
77
77
 
78
78
  if (float.IsNaN(aimX) || float.IsNaN(aimY))
79
79
  {
@@ -283,7 +283,7 @@
283
283
  // optional delay execution from happening on 0, 1, 2, ... n-1 to 1, 2, ... n
284
284
  if (
285
285
  totalExecuted < totalCount
286
- && (totalExecuted + (delay ? 1f : 0f)) / totalCount <= percent
286
+ && ((totalExecuted + (delay ? 1f : 0f)) / totalCount) <= percent
287
287
  )
288
288
  {
289
289
  action();
@@ -137,9 +137,11 @@
137
137
  const string sizeCheck = "size=";
138
138
  AddDecoration(
139
139
  format =>
140
- format.StartsWith(sizeCheck, StringComparison.OrdinalIgnoreCase)
141
- && int.TryParse(format.Substring(sizeCheck.Length), out _)
142
- || int.TryParse(format, out _),
140
+ (
141
+ format.StartsWith(sizeCheck, StringComparison.OrdinalIgnoreCase)
142
+ && int.TryParse(format.Substring(sizeCheck.Length), out _)
143
+ || int.TryParse(format, out _)
144
+ ),
143
145
  format: (format, value) =>
144
146
  {
145
147
  if (!int.TryParse(format, out int size))
@@ -371,26 +373,11 @@
371
373
  )
372
374
  {
373
375
  bool stopLooping = false;
374
- foreach (
375
- KeyValuePair<
376
- int,
377
- List<(
378
- string tag,
379
- bool editorOnly,
380
- Func<string, bool> predicate,
381
- Func<string, object, string> formatter
382
- )>
383
- > entry in _matchingDecorations
384
- )
376
+ foreach (var entry in _matchingDecorations)
385
377
  {
386
378
  for (int i = 0; i < entry.Value.Count; i++)
387
379
  {
388
- (
389
- string tag,
390
- bool editorOnly,
391
- Func<string, bool> predicate,
392
- Func<string, object, string> formatter
393
- ) existingDecoration = entry.Value[i];
380
+ var existingDecoration = entry.Value[i];
394
381
  if (
395
382
  !string.Equals(
396
383
  existingDecoration.tag,
@@ -472,17 +459,7 @@
472
459
  ) decoration
473
460
  )
474
461
  {
475
- foreach (
476
- KeyValuePair<
477
- int,
478
- List<(
479
- string tag,
480
- bool editorOnly,
481
- Func<string, bool> predicate,
482
- Func<string, object, string> formatter
483
- )>
484
- > entry in _matchingDecorations
485
- )
462
+ foreach (var entry in _matchingDecorations)
486
463
  {
487
464
  for (int i = 0; i < entry.Value.Count; ++i)
488
465
  {
@@ -3,12 +3,11 @@
3
3
  using System;
4
4
  using Extension;
5
5
  using UnityEditor;
6
+ using UnityEditor.SceneManagement;
6
7
  using UnityEngine;
7
8
  using UnityEngine.SceneManagement;
8
9
  using Object = UnityEngine.Object;
9
- #if UNITY_EDITOR
10
- using UnityEditor.SceneManagement;
11
- #endif
10
+
12
11
  public static partial class Helpers
13
12
  {
14
13
  public static T Find<T>(this Object component, string tag, bool log = true)
@@ -157,7 +156,7 @@
157
156
  }
158
157
  }
159
158
 
160
- Transform transform = component as Transform ?? component.transform;
159
+ Transform transform = (component as Transform) ?? component.transform;
161
160
  if (transform == null)
162
161
  {
163
162
  return;
@@ -188,7 +187,7 @@
188
187
  behavior.enabled = enabled;
189
188
  }
190
189
 
191
- Transform transform = component as Transform ?? component.transform;
190
+ Transform transform = (component as Transform) ?? component.transform;
192
191
  if (transform == null)
193
192
  {
194
193
  return;
@@ -1,7 +1,6 @@
1
1
  using System.Runtime.CompilerServices;
2
2
 
3
3
  [assembly: InternalsVisibleTo(assemblyName: "WallstopStudios.UnityHelpers.Styles")]
4
- [assembly: InternalsVisibleTo(assemblyName: "WallstopStudios.UnityHelpers.Editor")]
5
4
 
6
5
  namespace WallstopStudios.UnityHelpers.Core.Helper
7
6
  {
@@ -9,7 +8,7 @@ namespace WallstopStudios.UnityHelpers.Core.Helper
9
8
  {
10
9
  public static string SanitizePath(this string path)
11
10
  {
12
- return path?.Replace('\\', '/');
11
+ return path.Replace('\\', '/');
13
12
  }
14
13
  }
15
14
  }
@@ -11,7 +11,7 @@
11
11
  public static DotNetRandom Instance => ThreadLocalRandom<DotNetRandom>.Instance;
12
12
 
13
13
  public override RandomState InternalState =>
14
- new(unchecked((ulong)_seed), state2: _numberGenerated);
14
+ new RandomState(unchecked((ulong)_seed), state2: _numberGenerated);
15
15
 
16
16
  private ulong _numberGenerated;
17
17
  private int _seed;
@@ -45,7 +45,7 @@
45
45
  ulong z = _state;
46
46
  z = (z ^ (z >> 30)) * 0xBF58476D1CE4E5B9UL;
47
47
  z = (z ^ (z >> 27)) * 0x94D049BB133111EBUL;
48
- z ^= z >> 31;
48
+ z ^= (z >> 31);
49
49
 
50
50
  return (uint)z;
51
51
  }
@@ -54,11 +54,11 @@
54
54
  private static uint NextUintInternal(ref uint seed)
55
55
  {
56
56
  seed *= BitNoise1;
57
- seed ^= seed >> 8;
57
+ seed ^= (seed >> 8);
58
58
  seed += BitNoise2;
59
- seed ^= seed << 8;
59
+ seed ^= (seed << 8);
60
60
  seed *= BitNoise3;
61
- seed ^= seed >> 8;
61
+ seed ^= (seed >> 8);
62
62
  return seed;
63
63
  }
64
64
 
@@ -68,17 +68,17 @@
68
68
  uint result = unchecked((uint)x);
69
69
  result *= BitNoise1;
70
70
  result += seed;
71
- result ^= result >> 8;
71
+ result ^= (result >> 8);
72
72
  result += BitNoise2;
73
- result ^= result << 8;
73
+ result ^= (result << 8);
74
74
  result *= BitNoise3;
75
- result ^= result >> 8;
75
+ result ^= (result >> 8);
76
76
  return (result >> 8) * MagicFloat;
77
77
  }
78
78
 
79
79
  private static float NextNoise(int x, int y, uint seed)
80
80
  {
81
- return NextNoise(x + LargePrime * y, seed);
81
+ return NextNoise(x + (LargePrime * y), seed);
82
82
  }
83
83
  }
84
84
  }
@@ -5,7 +5,7 @@
5
5
  public static class ThreadLocalRandom<T>
6
6
  where T : IRandom, new()
7
7
  {
8
- private static readonly ThreadLocal<T> RandomCache = new(() => new T());
8
+ private static readonly ThreadLocal<T> RandomCache = new ThreadLocal<T>(() => new T());
9
9
 
10
10
  public static T Instance => RandomCache.Value;
11
11
  }
@@ -16,7 +16,7 @@
16
16
 
17
17
  public static WyRandom Instance => ThreadLocalRandom<WyRandom>.Instance;
18
18
 
19
- public override RandomState InternalState => new(_state);
19
+ public override RandomState InternalState => new RandomState(_state);
20
20
 
21
21
  private ulong _state;
22
22
 
@@ -297,7 +297,7 @@
297
297
  if (cosmeticEffectData.RequiresInstancing)
298
298
  {
299
299
  this.LogWarn(
300
- $"Double-deregistration detected for handle {handle:json}. Existing handles: [{string.Join(",", _instancedCosmeticEffects.Keys)}]."
300
+ $"Double-deregistration detected for handle {handle:json}. Existing handles: [{(string.Join(",", _instancedCosmeticEffects.Keys))}]."
301
301
  );
302
302
  continue;
303
303
  }