com.wallstop-studios.unity-helpers 2.0.0-rc59 → 2.0.0-rc61

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.
@@ -29,7 +29,16 @@ jobs:
29
29
  run: |
30
30
  if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
31
31
  echo "Manual trigger detected. Skipping version check."
32
+ NEW_VERSION=$(jq -r '.version' package.json)
33
+ echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV
32
34
  echo "should_publish=true" >> $GITHUB_ENV
35
+ if [[ "$NEW_VERSION" == *"rc"* ]]; then
36
+ echo "This is a pre-release (next tag)."
37
+ echo "NPM_TAG=next" >> $GITHUB_ENV
38
+ else
39
+ echo "This is a stable release (latest tag)."
40
+ echo "NPM_TAG=latest" >> $GITHUB_ENV
41
+ fi
33
42
  else
34
43
  PREV_VERSION=$(git show HEAD~1:package.json | jq -r '.version' || echo "0.0.0")
35
44
  NEW_VERSION=$(jq -r '.version' package.json)
@@ -61,6 +61,11 @@
61
61
  [WShowIf(nameof(applyFilterMode))]
62
62
  public FilterMode filterMode = FilterMode.Point;
63
63
 
64
+ public bool applyCrunchCompression;
65
+
66
+ [WShowIf(nameof(applyCrunchCompression))]
67
+ public bool useCrunchCompression;
68
+
64
69
  public string name = string.Empty;
65
70
  }
66
71
 
@@ -87,7 +92,7 @@
87
92
 
88
93
  private void OnWizardCreate()
89
94
  {
90
- HashSet<string> uniqueDirectories = new();
95
+ HashSet<string> uniqueDirectories = new(StringComparer.OrdinalIgnoreCase);
91
96
  foreach (
92
97
  string assetPath in directories
93
98
  .Where(Objects.NotNull)
@@ -101,14 +106,19 @@
101
106
  }
102
107
  }
103
108
 
104
- HashSet<string> processedSpritePaths = new();
109
+ HashSet<string> processedSpritePaths = new(StringComparer.OrdinalIgnoreCase);
105
110
  Queue<string> directoriesToCheck = new(uniqueDirectories);
106
111
  int spriteCount = 0;
107
112
  while (directoriesToCheck.TryDequeue(out string directoryPath))
108
113
  {
109
114
  foreach (string fullFilePath in Directory.EnumerateFiles(directoryPath))
110
115
  {
111
- if (!spriteFileExtensions.Contains(Path.GetExtension(fullFilePath)))
116
+ if (
117
+ !spriteFileExtensions.Contains(
118
+ Path.GetExtension(fullFilePath),
119
+ StringComparer.OrdinalIgnoreCase
120
+ )
121
+ )
112
122
  {
113
123
  continue;
114
124
  }
@@ -150,7 +160,7 @@
150
160
  string filePath in sprites
151
161
  .Where(Objects.NotNull)
152
162
  .Select(AssetDatabase.GetAssetPath)
153
- .Where(Objects.NotNull)
163
+ .Where(path => !string.IsNullOrWhiteSpace(path))
154
164
  )
155
165
  {
156
166
  if (
@@ -171,26 +181,27 @@
171
181
 
172
182
  private bool TryUpdateTextureSettings(string filePath)
173
183
  {
174
- bool changed = false;
175
184
  if (string.IsNullOrWhiteSpace(filePath))
176
185
  {
177
- return changed;
186
+ return false;
178
187
  }
179
188
 
180
189
  TextureImporter textureImporter = AssetImporter.GetAtPath(filePath) as TextureImporter;
181
190
  if (textureImporter == null)
182
191
  {
183
- return changed;
192
+ return false;
184
193
  }
185
194
 
186
195
  SpriteSettings spriteData = spriteSettings.Find(settings =>
187
- string.IsNullOrWhiteSpace(settings.name) || filePath.Contains(settings.name)
196
+ string.IsNullOrWhiteSpace(settings.name)
197
+ || filePath.Contains(settings.name, StringComparison.OrdinalIgnoreCase)
188
198
  );
189
199
  if (spriteData == null)
190
200
  {
191
- return changed;
201
+ return false;
192
202
  }
193
203
 
204
+ bool changed = false;
194
205
  if (spriteData.applyPixelsPerUnit)
195
206
  {
196
207
  // ReSharper disable once CompareOfFloatsByEqualityOperator
@@ -210,6 +221,12 @@
210
221
  textureImporter.mipmapEnabled = spriteData.generateMipMaps;
211
222
  }
212
223
 
224
+ if (spriteData.applyCrunchCompression)
225
+ {
226
+ changed |= textureImporter.crunchedCompression != spriteData.useCrunchCompression;
227
+ textureImporter.crunchedCompression = spriteData.useCrunchCompression;
228
+ }
229
+
213
230
  bool changedSettings = false;
214
231
  TextureImporterSettings settings = new();
215
232
  textureImporter.ReadTextureSettings(settings);
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "WallstopStudios.UnityHelpers.Editor",
3
- "rootNamespace": "",
3
+ "rootNamespace": "UnityHelpers",
4
4
  "references": [
5
5
  "WallstopStudios.UnityHelpers"
6
6
  ],
package/README.md CHANGED
@@ -133,17 +133,17 @@ random.NextNoiseMap(width, height); // A configurable noise map generated using
133
133
 
134
134
  | Random | NextBool | Next | NextUInt | NextFloat | NextDouble | NextUint - Range | NextInt - Range |
135
135
  | ------ | -------- | ---- | -------- | --------- | ---------- | ---------------- | --------------- |
136
- | PcgRandom | 34,260,478 | 34,303,866 | 35,148,246 | 24,818,438 | 30,034,632 |22,436,474 |20,801,797 |
137
- | SystemRandom | 28,698,806 | 30,040,782 | 20,435,092 | 24,079,399 | 27,284,147 |20,735,769 |19,861,780 |
138
- | SquirrelRandom | 33,285,784 | 33,439,909 | 34,611,893 | 23,885,731 | 28,958,725 |21,520,279 |20,311,372 |
139
- | XorShiftRandom | 34,695,989 | 35,147,320 | 35,997,718 | 25,248,238 | 31,582,991 |22,679,928 |21,255,319 |
140
- | DotNetRandom | 18,097,489 | 18,191,042 | 18,783,063 | 14,061,444 | 15,730,439 |13,284,050 |12,596,913 |
141
- | WyRandom | 28,490,852 | 29,086,052 | 29,724,907 | 20,252,065 | 24,542,201 |18,474,790 |17,404,641 |
142
- | SplitMix64 | 34,301,843 | 34,343,404 | 35,512,284 | 24,289,416 | 30,586,231 |22,470,330 |20,850,965 |
143
- | RomuDuo | 32,969,889 | 33,413,212 | 34,339,227 | 23,755,059 | 29,483,136 |21,671,641 |20,253,479 |
144
- | XorShiroRandom | 31,529,025 | 31,717,709 | 32,536,277 | 22,421,715 | 27,619,417 |20,843,993 |19,270,063 |
145
- | UnityRandom | 24,925,268 | 24,830,594 | 26,429,283 | 17,864,528 | 21,206,384 |16,376,626 |15,528,972 |
146
- | LinearCongruentialGenerator | 35,013,818 | 35,025,182 | 35,843,533 | 25,093,401 | 31,553,487 |22,579,798 |21,211,175 |
136
+ | PcgRandom | 168,140,000 | 168,290,000 | 230,950,000 | 92,140,000 | 92,400,000 |42,940,000 |38,430,000 |
137
+ | SystemRandom | 78,180,000 | 89,840,000 | 37,690,000 | 72,460,000 | 72,880,000 |37,930,000 |33,940,000 |
138
+ | SquirrelRandom | 128,120,000 | 128,190,000 | 163,060,000 | 78,140,000 | 78,720,000 |38,040,000 |36,310,000 |
139
+ | XorShiftRandom | 179,350,000 | 179,350,000 | 256,370,000 | 95,560,000 | 95,590,000 |43,750,000 |39,640,000 |
140
+ | DotNetRandom | 31,610,000 | 31,610,000 | 33,380,000 | 26,710,000 | 27,130,000 |20,120,000 |18,880,000 |
141
+ | WyRandom | 77,910,000 | 77,880,000 | 88,780,000 | 55,640,000 | 55,270,000 |31,810,000 |28,920,000 |
142
+ | SplitMix64 | 161,420,000 | 161,330,000 | 221,880,000 | 89,030,000 | 89,910,000 |42,160,000 |38,760,000 |
143
+ | RomuDuo | 132,840,000 | 133,150,000 | 171,810,000 | 80,290,000 | 79,120,000 |39,790,000 |36,620,000 |
144
+ | XorShiroRandom | 102,500,000 | 102,470,000 | 123,840,000 | 67,970,000 | 67,130,000 |35,850,000 |32,930,000 |
145
+ | UnityRandom | 52,440,000 | 52,440,000 | 57,630,000 | 41,670,000 | 39,940,000 |25,890,000 |25,140,000 |
146
+ | LinearCongruentialGenerator | 177,530,000 | 177,560,000 | 253,480,000 | 94,440,000 | 93,090,000 |42,920,000 |38,960,000 |
147
147
 
148
148
  # Spatial Trees
149
149
  There are three implemented 2D immutable spatial trees that can store generic objects, as long as there is some resolution function that can convert them into Vector2 spatial positions.
@@ -21,6 +21,7 @@
21
21
 
22
22
  public static class ChildComponentExtensions
23
23
  {
24
+ private static readonly List<Component> ChildCache = new();
24
25
  private static readonly Dictionary<
25
26
  Type,
26
27
  (FieldInfo field, Action<object, object> setter)[]
@@ -56,24 +57,27 @@
56
57
  {
57
58
  if (isArray)
58
59
  {
59
- List<Component> children = new();
60
+ ChildCache.Clear();
60
61
  foreach (Transform child in component.IterateOverAllChildren())
61
62
  {
62
- children.AddRange(
63
- child.GetComponentsInChildren(
63
+ foreach (
64
+ Component childComponent in child.GetComponentsInChildren(
64
65
  childComponentType,
65
66
  customAttribute.includeInactive
66
67
  )
67
- );
68
+ )
69
+ {
70
+ ChildCache.Add(childComponent);
71
+ }
68
72
  }
69
73
 
70
- foundChild = 0 < children.Count;
74
+ foundChild = 0 < ChildCache.Count;
71
75
 
72
76
  Array correctTypedArray = ReflectionHelpers.CreateArray(
73
77
  childComponentType,
74
- children.Count
78
+ ChildCache.Count
75
79
  );
76
- Array.Copy(children.ToArray(), correctTypedArray, children.Count);
80
+ Array.Copy(ChildCache.ToArray(), correctTypedArray, ChildCache.Count);
77
81
  setter(component, correctTypedArray);
78
82
  }
79
83
  else if (
@@ -216,11 +216,17 @@ namespace UnityHelpers.Core.Extension
216
216
  {
217
217
  List<Object> buffer = Buffers<Object>.List;
218
218
  buffer.Clear();
219
- buffer.AddRange(Disabled);
220
- buffer.RemoveAll(element => element != null);
221
- if (0 < buffer.Count)
219
+ foreach (Object disabled in Disabled)
222
220
  {
223
- Disabled.ExceptWith(buffer);
221
+ buffer.Add(disabled);
222
+ }
223
+
224
+ foreach (Object disabled in buffer)
225
+ {
226
+ if (disabled == null)
227
+ {
228
+ Disabled.Remove(disabled);
229
+ }
224
230
  }
225
231
  }
226
232
 
@@ -1,6 +1,7 @@
1
1
  namespace UnityHelpers.Utils
2
2
  {
3
3
  using System;
4
+ using Core.Attributes;
4
5
  using Core.Extension;
5
6
  using Core.Helper;
6
7
  using UnityEngine;
@@ -41,6 +42,7 @@
41
42
 
42
43
  protected virtual void Awake()
43
44
  {
45
+ this.AssignRelationalComponents();
44
46
  if (_instance == null)
45
47
  {
46
48
  _instance = this as T;
@@ -7,6 +7,8 @@
7
7
 
8
8
  public sealed class RandomPerformanceTests
9
9
  {
10
+ private const int NumInvocationsPerIteration = 10_000;
11
+
10
12
  [Test]
11
13
  public void Benchmark()
12
14
  {
@@ -63,8 +65,11 @@
63
65
  Stopwatch timer = Stopwatch.StartNew();
64
66
  do
65
67
  {
66
- _ = random.Next();
67
- ++count;
68
+ for (int i = 0; i < NumInvocationsPerIteration; ++i)
69
+ {
70
+ _ = random.Next();
71
+ ++count;
72
+ }
68
73
  } while (timer.Elapsed < timeout);
69
74
 
70
75
  return count;
@@ -77,8 +82,11 @@
77
82
  Stopwatch timer = Stopwatch.StartNew();
78
83
  do
79
84
  {
80
- _ = random.NextBool();
81
- ++count;
85
+ for (int i = 0; i < NumInvocationsPerIteration; ++i)
86
+ {
87
+ _ = random.NextBool();
88
+ ++count;
89
+ }
82
90
  } while (timer.Elapsed < timeout);
83
91
 
84
92
  return count;
@@ -91,8 +99,11 @@
91
99
  Stopwatch timer = Stopwatch.StartNew();
92
100
  do
93
101
  {
94
- _ = random.NextUint();
95
- ++count;
102
+ for (int i = 0; i < NumInvocationsPerIteration; ++i)
103
+ {
104
+ _ = random.NextUint();
105
+ ++count;
106
+ }
96
107
  } while (timer.Elapsed < timeout);
97
108
 
98
109
  return count;
@@ -105,8 +116,11 @@
105
116
  Stopwatch timer = Stopwatch.StartNew();
106
117
  do
107
118
  {
108
- _ = random.NextUint(1_000);
109
- ++count;
119
+ for (int i = 0; i < NumInvocationsPerIteration; ++i)
120
+ {
121
+ _ = random.NextUint(1_000);
122
+ ++count;
123
+ }
110
124
  } while (timer.Elapsed < timeout);
111
125
 
112
126
  return count;
@@ -119,8 +133,11 @@
119
133
  Stopwatch timer = Stopwatch.StartNew();
120
134
  do
121
135
  {
122
- _ = random.Next(1_000);
123
- ++count;
136
+ for (int i = 0; i < NumInvocationsPerIteration; ++i)
137
+ {
138
+ _ = random.Next(1_000);
139
+ ++count;
140
+ }
124
141
  } while (timer.Elapsed < timeout);
125
142
 
126
143
  return count;
@@ -133,8 +150,11 @@
133
150
  Stopwatch timer = Stopwatch.StartNew();
134
151
  do
135
152
  {
136
- _ = random.NextFloat();
137
- ++count;
153
+ for (int i = 0; i < NumInvocationsPerIteration; ++i)
154
+ {
155
+ _ = random.NextFloat();
156
+ ++count;
157
+ }
138
158
  } while (timer.Elapsed < timeout);
139
159
 
140
160
  return count;
@@ -147,8 +167,11 @@
147
167
  Stopwatch timer = Stopwatch.StartNew();
148
168
  do
149
169
  {
150
- _ = random.NextDouble();
151
- ++count;
170
+ for (int i = 0; i < NumInvocationsPerIteration; ++i)
171
+ {
172
+ _ = random.NextDouble();
173
+ ++count;
174
+ }
152
175
  } while (timer.Elapsed < timeout);
153
176
 
154
177
  return count;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "com.wallstop-studios.unity-helpers",
3
- "version": "2.0.0-rc59",
3
+ "version": "2.0.0-rc61",
4
4
  "displayName": "Unity Helpers",
5
5
  "description": "Various Unity Helper Library",
6
6
  "dependencies": {},