com.wallstop-studios.unity-helpers 2.0.0-rc59 → 2.0.0-rc60
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/.github/workflows/npm-publish.yml +9 -0
- package/README.md +11 -11
- package/Runtime/Core/Attributes/ChildComponentAttribute.cs +11 -7
- package/Runtime/Core/Extension/LoggingExtensions.cs +10 -4
- package/Runtime/Utils/RuntimeSingleton.cs +2 -0
- package/Tests/Runtime/Performance/RandomPerformanceTests.cs +37 -14
- package/package.json +1 -1
|
@@ -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)
|
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 |
|
|
137
|
-
| SystemRandom |
|
|
138
|
-
| SquirrelRandom |
|
|
139
|
-
| XorShiftRandom |
|
|
140
|
-
| DotNetRandom |
|
|
141
|
-
| WyRandom |
|
|
142
|
-
| SplitMix64 |
|
|
143
|
-
| RomuDuo |
|
|
144
|
-
| XorShiroRandom |
|
|
145
|
-
| UnityRandom |
|
|
146
|
-
| LinearCongruentialGenerator |
|
|
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
|
-
|
|
60
|
+
ChildCache.Clear();
|
|
60
61
|
foreach (Transform child in component.IterateOverAllChildren())
|
|
61
62
|
{
|
|
62
|
-
|
|
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 <
|
|
74
|
+
foundChild = 0 < ChildCache.Count;
|
|
71
75
|
|
|
72
76
|
Array correctTypedArray = ReflectionHelpers.CreateArray(
|
|
73
77
|
childComponentType,
|
|
74
|
-
|
|
78
|
+
ChildCache.Count
|
|
75
79
|
);
|
|
76
|
-
Array.Copy(
|
|
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
|
-
|
|
220
|
-
buffer.RemoveAll(element => element != null);
|
|
221
|
-
if (0 < buffer.Count)
|
|
219
|
+
foreach (Object disabled in Disabled)
|
|
222
220
|
{
|
|
223
|
-
|
|
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
|
-
|
|
67
|
-
|
|
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
|
-
|
|
81
|
-
|
|
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
|
-
|
|
95
|
-
|
|
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
|
-
|
|
109
|
-
|
|
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
|
-
|
|
123
|
-
|
|
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
|
-
|
|
137
|
-
|
|
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
|
-
|
|
151
|
-
|
|
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;
|