com.wallstop-studios.unity-helpers 2.0.0 → 2.0.1
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/format-on-demand.yml +2 -2
- package/.github/workflows/markdown-json.yml +1 -1
- package/.github/workflows/npm-publish.yml +1 -1
- package/.github/workflows/prettier-autofix.yml +4 -4
- package/.github/workflows/yaml-format-lint.yml +1 -1
- package/Docs/EFFECTS_SYSTEM.md +1316 -0
- package/{EFFECTS_SYSTEM_TUTORIAL.md → Docs/EFFECTS_SYSTEM_TUTORIAL.md} +1 -1
- package/{GETTING_STARTED.md → Docs/GETTING_STARTED.md} +10 -8
- package/{GLOSSARY.md → Docs/GLOSSARY.md} +4 -4
- package/Docs/HELPER_UTILITIES.md +885 -0
- package/Docs/HELPER_UTILITIES.md.meta +7 -0
- package/{INDEX.md → Docs/INDEX.md} +107 -62
- package/Docs/MATH_AND_EXTENSIONS.md +1039 -0
- package/{RANDOM_PERFORMANCE.md → Docs/RANDOM_PERFORMANCE.md} +15 -15
- package/{RELATIONAL_COMPONENTS.md → Docs/RELATIONAL_COMPONENTS.md} +21 -3
- package/{SPATIAL_TREES_2D_GUIDE.md → Docs/SPATIAL_TREES_2D_GUIDE.md} +2 -2
- package/{SPATIAL_TREES_3D_GUIDE.md → Docs/SPATIAL_TREES_3D_GUIDE.md} +1 -1
- package/{SPATIAL_TREE_2D_PERFORMANCE.md → Docs/SPATIAL_TREE_2D_PERFORMANCE.md} +64 -64
- package/{SPATIAL_TREE_3D_PERFORMANCE.md → Docs/SPATIAL_TREE_3D_PERFORMANCE.md} +64 -64
- package/Docs/UTILITY_COMPONENTS.md +906 -0
- package/Docs/UTILITY_COMPONENTS.md.meta +7 -0
- package/Docs/VISUAL_COMPONENTS.md +337 -0
- package/Docs/VISUAL_COMPONENTS.md.meta +7 -0
- package/Editor/Sprites/AnimationCopier.cs +3 -3
- package/README.md +69 -62
- package/Runtime/AssemblyInfo.cs +2 -0
- package/Runtime/Core/DataStructure/KDTree3D.cs +1 -1
- package/Runtime/Core/DataStructure/OctTree3D.cs +1 -1
- package/Runtime/Core/Extension/AsyncOperationExtensions.cs +122 -0
- package/Runtime/Core/Serialization/ProtobufUnitySurrogates.cs +24 -29
- package/Runtime/Integrations/Reflex/AssemblyInfo.cs +7 -0
- package/Runtime/Integrations/Reflex/AssemblyInfo.cs.meta +11 -0
- package/Runtime/Integrations/Reflex/ContainerRelationalExtensions.cs +198 -0
- package/Runtime/Integrations/Reflex/ContainerRelationalExtensions.cs.meta +11 -0
- package/Runtime/Integrations/Reflex/RelationalComponentsInstaller.cs +86 -0
- package/Runtime/Integrations/Reflex/RelationalComponentsInstaller.cs.meta +11 -0
- package/Runtime/Integrations/Reflex/RelationalReflexSceneBootstrapper.cs +316 -0
- package/Runtime/Integrations/Reflex/RelationalReflexSceneBootstrapper.cs.meta +11 -0
- package/Runtime/Integrations/Reflex/RelationalSceneAssignmentOptions.cs +86 -0
- package/Runtime/Integrations/Reflex/RelationalSceneAssignmentOptions.cs.meta +11 -0
- package/Runtime/Integrations/Reflex/WallstopStudios.UnityHelpers.Integration.Reflex.asmdef +20 -0
- package/Runtime/Integrations/Reflex/WallstopStudios.UnityHelpers.Integration.Reflex.asmdef.meta +7 -0
- package/Runtime/Integrations/Reflex.meta +8 -0
- package/Runtime/Utils/ScriptableObjectSingleton.cs +1 -1
- package/Samples~/DI - Reflex/README.md +527 -0
- package/Samples~/DI - Reflex/README.md.meta +7 -0
- package/Samples~/DI - Reflex/Scripts/ReflexPaletteService.cs +36 -0
- package/Samples~/DI - Reflex/Scripts/ReflexPaletteService.cs.meta +11 -0
- package/Samples~/DI - Reflex/Scripts/ReflexRelationalConsumer.cs +79 -0
- package/Samples~/DI - Reflex/Scripts/ReflexRelationalConsumer.cs.meta +11 -0
- package/Samples~/DI - Reflex/Scripts/ReflexSampleInstaller.cs +30 -0
- package/Samples~/DI - Reflex/Scripts/ReflexSampleInstaller.cs.meta +11 -0
- package/Samples~/DI - Reflex/Scripts/ReflexSpawner.cs +79 -0
- package/Samples~/DI - Reflex/Scripts/ReflexSpawner.cs.meta +11 -0
- package/Samples~/DI - Reflex/Scripts/Samples.UnityHelpers.DI.Reflex.asmdef +26 -0
- package/Samples~/DI - Reflex/Scripts/Samples.UnityHelpers.DI.Reflex.asmdef.meta +9 -0
- package/Samples~/DI - Reflex/Scripts.meta +8 -0
- package/Samples~/DI - Reflex.meta +8 -0
- package/Samples~/DI - VContainer/README.md +6 -5
- package/Samples~/DI - Zenject/README.md +6 -5
- package/Tests/Editor/Core/Attributes/RelationalComponentAssignerTests.cs +29 -31
- package/Tests/Editor/Integrations/Reflex/ReflexIntegrationCompilationTests.cs +41 -0
- package/Tests/Editor/Integrations/Reflex/ReflexIntegrationCompilationTests.cs.meta +11 -0
- package/Tests/Editor/Integrations/Reflex/WallstopStudios.UnityHelpers.Tests.Editor.Reflex.asmdef +27 -0
- package/Tests/Editor/Integrations/Reflex/WallstopStudios.UnityHelpers.Tests.Editor.Reflex.asmdef.meta +7 -0
- package/Tests/Editor/Integrations/Reflex.meta +8 -0
- package/Tests/Editor/Integrations/VContainer/VContainerRelationalEntryPointTests.cs +15 -16
- package/Tests/Editor/Integrations/VContainer/VContainerRelationalHelpersTests.cs +7 -13
- package/Tests/Editor/Integrations/Zenject/ZenjectRelationalHelpersTests.cs +7 -11
- package/Tests/Editor/Integrations/Zenject/ZenjectRelationalInitializerTests.cs +19 -21
- package/Tests/Editor/PersistentDirectorySettingsTests.cs +0 -1
- package/Tests/Editor/Sprites/AnimationCopierFilterTests.cs +0 -1
- package/Tests/Editor/Sprites/AnimationViewerWindowTests.cs +2 -2
- package/Tests/Editor/Tools/ImageBlurToolTests.cs +1 -1
- package/Tests/Editor/Utils/CommonTestBase.cs +17 -0
- package/Tests/Editor/Utils/ScriptableObjectSingletonCreatorTests.cs +1 -1
- package/Tests/Runtime/Extensions/AsyncOperationExtensionsTests.cs +179 -0
- package/Tests/Runtime/Extensions/RandomExtensionTests.cs +55 -0
- package/Tests/Runtime/Integrations/Reflex/RelationalComponentsReflexTests.cs +445 -0
- package/Tests/Runtime/Integrations/Reflex/RelationalComponentsReflexTests.cs.meta +11 -0
- package/Tests/Runtime/Integrations/Reflex/WallstopStudios.UnityHelpers.Tests.Runtime.Reflex.asmdef +28 -0
- package/Tests/Runtime/Integrations/Reflex/WallstopStudios.UnityHelpers.Tests.Runtime.Reflex.asmdef.meta +7 -0
- package/Tests/Runtime/Integrations/Reflex.meta +8 -0
- package/Tests/Runtime/Integrations/VContainer/RelationalComponentsVContainerTests.cs +24 -29
- package/Tests/Runtime/Integrations/VContainer/RelationalObjectPoolsVContainerTests.cs +8 -3
- package/Tests/Runtime/Integrations/Zenject/RelationalComponentsZenjectTests.cs +10 -20
- package/Tests/Runtime/Performance/RandomPerformanceTests.cs +1 -1
- package/Tests/Runtime/Performance/SpatialTree2DPerformanceTests.cs +1 -1
- package/Tests/Runtime/Performance/SpatialTree3DPerformanceTests.cs +1 -1
- package/Tests/Runtime/Serialization/JsonRoundtripComprehensiveTests.cs +4 -9
- package/Tests/Runtime/Serialization/ProtoRoundtripComprehensiveTests.cs +13 -13
- package/Tests/Runtime/TestUtils/CommonTestBase.cs +11 -0
- package/Tests/Runtime/TestUtils/ReflexTestSupport.cs +111 -0
- package/Tests/Runtime/TestUtils/ReflexTestSupport.cs.meta +12 -0
- package/Tests/Runtime/Utils/MatchColliderToSpriteTests.cs +4 -4
- package/Tests/TestUtils.meta +8 -0
- package/package.json +6 -1
- package/EFFECTS_SYSTEM.md +0 -242
- package/MATH_AND_EXTENSIONS.md +0 -316
- /package/{CHANGELOG.md → Docs/CHANGELOG.md} +0 -0
- /package/{CHANGELOG.md.meta → Docs/CHANGELOG.md.meta} +0 -0
- /package/{CONTRIBUTING.md → Docs/CONTRIBUTING.md} +0 -0
- /package/{CONTRIBUTING.md.meta → Docs/CONTRIBUTING.md.meta} +0 -0
- /package/{DATA_STRUCTURES.md → Docs/DATA_STRUCTURES.md} +0 -0
- /package/{DATA_STRUCTURES.md.meta → Docs/DATA_STRUCTURES.md.meta} +0 -0
- /package/{EDITOR_TOOLS_GUIDE.md → Docs/EDITOR_TOOLS_GUIDE.md} +0 -0
- /package/{EDITOR_TOOLS_GUIDE.md.meta → Docs/EDITOR_TOOLS_GUIDE.md.meta} +0 -0
- /package/{EFFECTS_SYSTEM.md.meta → Docs/EFFECTS_SYSTEM.md.meta} +0 -0
- /package/{EFFECTS_SYSTEM_TUTORIAL.md.meta → Docs/EFFECTS_SYSTEM_TUTORIAL.md.meta} +0 -0
- /package/{GETTING_STARTED.md.meta → Docs/GETTING_STARTED.md.meta} +0 -0
- /package/{GLOSSARY.md.meta → Docs/GLOSSARY.md.meta} +0 -0
- /package/{HULLS.md → Docs/HULLS.md} +0 -0
- /package/{HULLS.md.meta → Docs/HULLS.md.meta} +0 -0
- /package/{INDEX.md.meta → Docs/INDEX.md.meta} +0 -0
- /package/{LICENSE.md → Docs/LICENSE.md} +0 -0
- /package/{LICENSE.md.meta → Docs/LICENSE.md.meta} +0 -0
- /package/{MATH_AND_EXTENSIONS.md.meta → Docs/MATH_AND_EXTENSIONS.md.meta} +0 -0
- /package/{RANDOM_PERFORMANCE.md.meta → Docs/RANDOM_PERFORMANCE.md.meta} +0 -0
- /package/{REFLECTION_HELPERS.md → Docs/REFLECTION_HELPERS.md} +0 -0
- /package/{REFLECTION_HELPERS.md.meta → Docs/REFLECTION_HELPERS.md.meta} +0 -0
- /package/{RELATIONAL_COMPONENTS.md.meta → Docs/RELATIONAL_COMPONENTS.md.meta} +0 -0
- /package/{SERIALIZATION.md → Docs/SERIALIZATION.md} +0 -0
- /package/{SERIALIZATION.md.meta → Docs/SERIALIZATION.md.meta} +0 -0
- /package/{SINGLETONS.md → Docs/SINGLETONS.md} +0 -0
- /package/{SINGLETONS.md.meta → Docs/SINGLETONS.md.meta} +0 -0
- /package/{SPATIAL_TREES_2D_GUIDE.md.meta → Docs/SPATIAL_TREES_2D_GUIDE.md.meta} +0 -0
- /package/{SPATIAL_TREES_3D_GUIDE.md.meta → Docs/SPATIAL_TREES_3D_GUIDE.md.meta} +0 -0
- /package/{SPATIAL_TREE_2D_PERFORMANCE.md.meta → Docs/SPATIAL_TREE_2D_PERFORMANCE.md.meta} +0 -0
- /package/{SPATIAL_TREE_3D_PERFORMANCE.md.meta → Docs/SPATIAL_TREE_3D_PERFORMANCE.md.meta} +0 -0
- /package/{SPATIAL_TREE_SEMANTICS.md → Docs/SPATIAL_TREE_SEMANTICS.md} +0 -0
- /package/{SPATIAL_TREE_SEMANTICS.md.meta → Docs/SPATIAL_TREE_SEMANTICS.md.meta} +0 -0
- /package/{THIRD_PARTY_NOTICES.md → Docs/THIRD_PARTY_NOTICES.md} +0 -0
- /package/{THIRD_PARTY_NOTICES.md.meta → Docs/THIRD_PARTY_NOTICES.md.meta} +0 -0
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
#if VCONTAINER_PRESENT
|
|
2
2
|
namespace WallstopStudios.UnityHelpers.Tests.Integrations.VContainer
|
|
3
3
|
{
|
|
4
|
-
using System;
|
|
5
4
|
using global::VContainer;
|
|
6
5
|
using NUnit.Framework;
|
|
7
6
|
using UnityEngine;
|
|
@@ -12,10 +11,16 @@ namespace WallstopStudios.UnityHelpers.Tests.Integrations.VContainer
|
|
|
12
11
|
|
|
13
12
|
public sealed class RelationalObjectPoolsVContainerTests : CommonTestBase
|
|
14
13
|
{
|
|
14
|
+
[SetUp]
|
|
15
|
+
public void CommonSetup()
|
|
16
|
+
{
|
|
17
|
+
ReflexTestSupport.EnsureReflexSettings();
|
|
18
|
+
}
|
|
19
|
+
|
|
15
20
|
[Test]
|
|
16
21
|
public void ComponentPoolGetWithRelationsInjectsAndAssigns()
|
|
17
22
|
{
|
|
18
|
-
ContainerBuilder builder = new
|
|
23
|
+
ContainerBuilder builder = new();
|
|
19
24
|
IObjectResolver resolver = builder.Build();
|
|
20
25
|
|
|
21
26
|
ObjectPool<TestComponent> pool = RelationalObjectPools.CreatePoolWithRelations(
|
|
@@ -46,7 +51,7 @@ namespace WallstopStudios.UnityHelpers.Tests.Integrations.VContainer
|
|
|
46
51
|
[Test]
|
|
47
52
|
public void GameObjectPoolGetWithRelationsInjectsAndAssigns()
|
|
48
53
|
{
|
|
49
|
-
ContainerBuilder builder = new
|
|
54
|
+
ContainerBuilder builder = new();
|
|
50
55
|
IObjectResolver resolver = builder.Build();
|
|
51
56
|
|
|
52
57
|
GameObject prefab = Track(new GameObject("PrefabRoot"));
|
|
@@ -20,6 +20,7 @@ namespace WallstopStudios.UnityHelpers.Tests.Integrations.Zenject
|
|
|
20
20
|
[SetUp]
|
|
21
21
|
public void Setup()
|
|
22
22
|
{
|
|
23
|
+
ReflexTestSupport.EnsureReflexSettings();
|
|
23
24
|
Container = new DiContainer();
|
|
24
25
|
}
|
|
25
26
|
|
|
@@ -200,16 +201,12 @@ namespace WallstopStudios.UnityHelpers.Tests.Integrations.Zenject
|
|
|
200
201
|
public System.Collections.IEnumerator SceneLoadListenerAssignsAdditiveSceneSinglePass()
|
|
201
202
|
{
|
|
202
203
|
AttributeMetadataCache cache = CreateCacheFor(typeof(ZenjectRelationalTester));
|
|
203
|
-
RelationalComponentAssigner assigner = new
|
|
204
|
-
RelationalSceneAssignmentOptions options = new
|
|
204
|
+
RelationalComponentAssigner assigner = new(cache);
|
|
205
|
+
RelationalSceneAssignmentOptions options = new(
|
|
205
206
|
includeInactive: true,
|
|
206
207
|
useSinglePassScan: true
|
|
207
208
|
);
|
|
208
|
-
RelationalSceneLoadListener listener = new
|
|
209
|
-
assigner,
|
|
210
|
-
cache,
|
|
211
|
-
options
|
|
212
|
-
);
|
|
209
|
+
RelationalSceneLoadListener listener = new(assigner, cache, options);
|
|
213
210
|
listener.Initialize();
|
|
214
211
|
TrackDisposable(listener);
|
|
215
212
|
|
|
@@ -238,16 +235,12 @@ namespace WallstopStudios.UnityHelpers.Tests.Integrations.Zenject
|
|
|
238
235
|
public System.Collections.IEnumerator SceneLoadListenerAssignsAdditiveSceneMultiPass()
|
|
239
236
|
{
|
|
240
237
|
AttributeMetadataCache cache = CreateCacheFor(typeof(ZenjectRelationalTester));
|
|
241
|
-
RelationalComponentAssigner assigner = new
|
|
242
|
-
RelationalSceneAssignmentOptions options = new
|
|
238
|
+
RelationalComponentAssigner assigner = new(cache);
|
|
239
|
+
RelationalSceneAssignmentOptions options = new(
|
|
243
240
|
includeInactive: true,
|
|
244
241
|
useSinglePassScan: false
|
|
245
242
|
);
|
|
246
|
-
RelationalSceneLoadListener listener = new
|
|
247
|
-
assigner,
|
|
248
|
-
cache,
|
|
249
|
-
options
|
|
250
|
-
);
|
|
243
|
+
RelationalSceneLoadListener listener = new(assigner, cache, options);
|
|
251
244
|
listener.Initialize();
|
|
252
245
|
TrackDisposable(listener);
|
|
253
246
|
|
|
@@ -526,14 +519,14 @@ namespace WallstopStudios.UnityHelpers.Tests.Integrations.Zenject
|
|
|
526
519
|
|
|
527
520
|
AttributeMetadataCache.RelationalFieldMetadata[] fields =
|
|
528
521
|
{
|
|
529
|
-
new
|
|
522
|
+
new(
|
|
530
523
|
nameof(ZenjectRelationalTester.parentBody),
|
|
531
524
|
AttributeMetadataCache.RelationalAttributeKind.Parent,
|
|
532
525
|
AttributeMetadataCache.FieldKind.Single,
|
|
533
526
|
typeof(Rigidbody).AssemblyQualifiedName,
|
|
534
527
|
isInterface: false
|
|
535
528
|
),
|
|
536
|
-
new
|
|
529
|
+
new(
|
|
537
530
|
nameof(ZenjectRelationalTester.childCollider),
|
|
538
531
|
AttributeMetadataCache.RelationalAttributeKind.Child,
|
|
539
532
|
AttributeMetadataCache.FieldKind.Single,
|
|
@@ -544,10 +537,7 @@ namespace WallstopStudios.UnityHelpers.Tests.Integrations.Zenject
|
|
|
544
537
|
|
|
545
538
|
AttributeMetadataCache.RelationalTypeMetadata[] relationalTypes =
|
|
546
539
|
{
|
|
547
|
-
new
|
|
548
|
-
componentType.AssemblyQualifiedName,
|
|
549
|
-
fields
|
|
550
|
-
),
|
|
540
|
+
new(componentType.AssemblyQualifiedName, fields),
|
|
551
541
|
};
|
|
552
542
|
|
|
553
543
|
cache._relationalTypeMetadata = relationalTypes;
|
|
@@ -294,7 +294,7 @@ namespace WallstopStudios.UnityHelpers.Tests.Performance
|
|
|
294
294
|
BenchmarkReadmeUpdater.UpdateSection(
|
|
295
295
|
"SPATIAL_TREE_BENCHMARKS",
|
|
296
296
|
finalReadmeLines,
|
|
297
|
-
"SPATIAL_TREE_2D_PERFORMANCE.md"
|
|
297
|
+
"Docs/SPATIAL_TREE_2D_PERFORMANCE.md"
|
|
298
298
|
);
|
|
299
299
|
|
|
300
300
|
yield break;
|
|
@@ -265,7 +265,7 @@ namespace WallstopStudios.UnityHelpers.Tests.Performance
|
|
|
265
265
|
BenchmarkReadmeUpdater.UpdateSection(
|
|
266
266
|
"SPATIAL_TREE_3D_BENCHMARKS",
|
|
267
267
|
finalReadmeLines,
|
|
268
|
-
"SPATIAL_TREE_3D_PERFORMANCE.md"
|
|
268
|
+
"Docs/SPATIAL_TREE_3D_PERFORMANCE.md"
|
|
269
269
|
);
|
|
270
270
|
|
|
271
271
|
yield break;
|
|
@@ -31,14 +31,9 @@ namespace WallstopStudios.UnityHelpers.Tests.Serialization
|
|
|
31
31
|
[Test]
|
|
32
32
|
public void AdaptersCollectionsRoundTrip()
|
|
33
33
|
{
|
|
34
|
-
List<FastVector3Int> list = new
|
|
35
|
-
{
|
|
36
|
-
new(1, 2, 3),
|
|
37
|
-
new(-4, 5, -6),
|
|
38
|
-
new(7, 0, -1),
|
|
39
|
-
};
|
|
34
|
+
List<FastVector3Int> list = new() { new(1, 2, 3), new(-4, 5, -6), new(7, 0, -1) };
|
|
40
35
|
|
|
41
|
-
Dictionary<string, FastVector2Int> map = new
|
|
36
|
+
Dictionary<string, FastVector2Int> map = new()
|
|
42
37
|
{
|
|
43
38
|
["a"] = new(9, -9),
|
|
44
39
|
["b"] = new(0, 1),
|
|
@@ -76,7 +71,7 @@ namespace WallstopStudios.UnityHelpers.Tests.Serialization
|
|
|
76
71
|
[Test]
|
|
77
72
|
public void CompositePayloadRoundTrips()
|
|
78
73
|
{
|
|
79
|
-
CompositePayload payload = new
|
|
74
|
+
CompositePayload payload = new()
|
|
80
75
|
{
|
|
81
76
|
fv2 = new FastVector2Int(-3, 7),
|
|
82
77
|
fv3 = new FastVector3Int(1, -2, 3),
|
|
@@ -147,7 +142,7 @@ namespace WallstopStudios.UnityHelpers.Tests.Serialization
|
|
|
147
142
|
[Test]
|
|
148
143
|
public void CompositePayloadRoundTripsWithFastOptions()
|
|
149
144
|
{
|
|
150
|
-
CompositePayload payload = new
|
|
145
|
+
CompositePayload payload = new()
|
|
151
146
|
{
|
|
152
147
|
fv2 = new FastVector2Int(9, -4),
|
|
153
148
|
fv3 = new FastVector3Int(5, 6, -7),
|
|
@@ -38,7 +38,7 @@ namespace WallstopStudios.UnityHelpers.Tests.Serialization
|
|
|
38
38
|
[Test]
|
|
39
39
|
public void Vector2RoundTrip()
|
|
40
40
|
{
|
|
41
|
-
Vector2 v = new
|
|
41
|
+
Vector2 v = new(1.5f, -2.25f);
|
|
42
42
|
Vector2 again = RoundTrip(v);
|
|
43
43
|
Assert.AreEqual(v.x, again.x, 0f, "Vector2 x should match");
|
|
44
44
|
Assert.AreEqual(v.y, again.y, 0f, "Vector2 y should match");
|
|
@@ -47,7 +47,7 @@ namespace WallstopStudios.UnityHelpers.Tests.Serialization
|
|
|
47
47
|
[Test]
|
|
48
48
|
public void Vector3RoundTrip()
|
|
49
49
|
{
|
|
50
|
-
Vector3 v = new
|
|
50
|
+
Vector3 v = new(-1.5f, 2.75f, 3.25f);
|
|
51
51
|
Vector3 again = RoundTrip(v);
|
|
52
52
|
Assert.AreEqual(v.x, again.x, 0f, "Vector3 x should match");
|
|
53
53
|
Assert.AreEqual(v.y, again.y, 0f, "Vector3 y should match");
|
|
@@ -57,12 +57,12 @@ namespace WallstopStudios.UnityHelpers.Tests.Serialization
|
|
|
57
57
|
[Test]
|
|
58
58
|
public void Vector2IntAndVector3IntRoundTrip()
|
|
59
59
|
{
|
|
60
|
-
Vector2Int v2i = new
|
|
60
|
+
Vector2Int v2i = new(int.MinValue + 1, int.MaxValue - 1);
|
|
61
61
|
Vector2Int v2iAgain = RoundTrip(v2i);
|
|
62
62
|
Assert.AreEqual(v2i.x, v2iAgain.x, "Vector2Int x should match");
|
|
63
63
|
Assert.AreEqual(v2i.y, v2iAgain.y, "Vector2Int y should match");
|
|
64
64
|
|
|
65
|
-
Vector3Int v3i = new
|
|
65
|
+
Vector3Int v3i = new(1, -2, 3);
|
|
66
66
|
Vector3Int v3iAgain = RoundTrip(v3i);
|
|
67
67
|
Assert.AreEqual(v3i.x, v3iAgain.x, "Vector3Int x should match");
|
|
68
68
|
Assert.AreEqual(v3i.y, v3iAgain.y, "Vector3Int y should match");
|
|
@@ -72,7 +72,7 @@ namespace WallstopStudios.UnityHelpers.Tests.Serialization
|
|
|
72
72
|
[Test]
|
|
73
73
|
public void QuaternionRoundTrip()
|
|
74
74
|
{
|
|
75
|
-
Quaternion q = new
|
|
75
|
+
Quaternion q = new(0.1f, 0.2f, 0.3f, 0.9f);
|
|
76
76
|
Quaternion again = RoundTrip(q);
|
|
77
77
|
Assert.AreEqual(q.x, again.x, 0f, "Quaternion x should match");
|
|
78
78
|
Assert.AreEqual(q.y, again.y, 0f, "Quaternion y should match");
|
|
@@ -83,14 +83,14 @@ namespace WallstopStudios.UnityHelpers.Tests.Serialization
|
|
|
83
83
|
[Test]
|
|
84
84
|
public void ColorAndColor32RoundTrip()
|
|
85
85
|
{
|
|
86
|
-
Color c = new
|
|
86
|
+
Color c = new(0.1f, 0.2f, 0.3f, 0.4f);
|
|
87
87
|
Color cAgain = RoundTrip(c);
|
|
88
88
|
Assert.AreEqual(c.r, cAgain.r, 0f, "Color r should match");
|
|
89
89
|
Assert.AreEqual(c.g, cAgain.g, 0f, "Color g should match");
|
|
90
90
|
Assert.AreEqual(c.b, cAgain.b, 0f, "Color b should match");
|
|
91
91
|
Assert.AreEqual(c.a, cAgain.a, 0f, "Color a should match");
|
|
92
92
|
|
|
93
|
-
Color32 c32 = new
|
|
93
|
+
Color32 c32 = new(10, 20, 30, 40);
|
|
94
94
|
Color32 c32Again = RoundTrip(c32);
|
|
95
95
|
Assert.AreEqual(c32.r, c32Again.r, "Color32 r should match");
|
|
96
96
|
Assert.AreEqual(c32.g, c32Again.g, "Color32 g should match");
|
|
@@ -113,11 +113,11 @@ namespace WallstopStudios.UnityHelpers.Tests.Serialization
|
|
|
113
113
|
[Test]
|
|
114
114
|
public void RectAndRectIntRoundTrip()
|
|
115
115
|
{
|
|
116
|
-
Rect r = new
|
|
116
|
+
Rect r = new(1.5f, 2.5f, 10f, 20f);
|
|
117
117
|
Rect rAgain = RoundTrip(r);
|
|
118
118
|
Assert.AreEqual(r, rAgain, "Rect should round-trip by value");
|
|
119
119
|
|
|
120
|
-
RectInt ri = new
|
|
120
|
+
RectInt ri = new(1, 2, 3, 4);
|
|
121
121
|
RectInt riAgain = RoundTrip(ri);
|
|
122
122
|
Assert.AreEqual(ri, riAgain, "RectInt should round-trip by value");
|
|
123
123
|
}
|
|
@@ -125,12 +125,12 @@ namespace WallstopStudios.UnityHelpers.Tests.Serialization
|
|
|
125
125
|
[Test]
|
|
126
126
|
public void BoundsAndBoundsIntRoundTrip()
|
|
127
127
|
{
|
|
128
|
-
Bounds b = new
|
|
128
|
+
Bounds b = new(new Vector3(1, 2, 3), new Vector3(4, 5, 6));
|
|
129
129
|
Bounds bAgain = RoundTrip(b);
|
|
130
130
|
Assert.AreEqual(b.center, bAgain.center, "Bounds center should round-trip");
|
|
131
131
|
Assert.AreEqual(b.size, bAgain.size, "Bounds size should round-trip");
|
|
132
132
|
|
|
133
|
-
BoundsInt bi = new
|
|
133
|
+
BoundsInt bi = new(new Vector3Int(1, 2, 3), new Vector3Int(4, 5, 6));
|
|
134
134
|
BoundsInt biAgain = RoundTrip(bi);
|
|
135
135
|
Assert.AreEqual(bi.position, biAgain.position, "BoundsInt position should round-trip");
|
|
136
136
|
Assert.AreEqual(bi.size, biAgain.size, "BoundsInt size should round-trip");
|
|
@@ -139,7 +139,7 @@ namespace WallstopStudios.UnityHelpers.Tests.Serialization
|
|
|
139
139
|
[Test]
|
|
140
140
|
public void ResolutionRoundTrip()
|
|
141
141
|
{
|
|
142
|
-
Resolution r = new
|
|
142
|
+
Resolution r = new() { width = 800, height = 600 };
|
|
143
143
|
Resolution rAgain = RoundTrip(r);
|
|
144
144
|
Assert.AreEqual(r.width, rAgain.width, "Resolution width should round-trip");
|
|
145
145
|
Assert.AreEqual(r.height, rAgain.height, "Resolution height should round-trip");
|
|
@@ -219,7 +219,7 @@ namespace WallstopStudios.UnityHelpers.Tests.Serialization
|
|
|
219
219
|
[Test]
|
|
220
220
|
public void CompositePayloadWithCollectionsRoundTrips()
|
|
221
221
|
{
|
|
222
|
-
Composite payload = new
|
|
222
|
+
Composite payload = new()
|
|
223
223
|
{
|
|
224
224
|
fv2 = new FastVector2Int(-3, 7),
|
|
225
225
|
fv3 = new FastVector3Int(1, -2, 3),
|
|
@@ -16,6 +16,17 @@ namespace WallstopStudios.UnityHelpers.Tests.TestUtils
|
|
|
16
16
|
/// </summary>
|
|
17
17
|
public abstract class CommonTestBase
|
|
18
18
|
{
|
|
19
|
+
/// <summary>
|
|
20
|
+
/// Ensures ReflexSettings singleton is present when the Reflex package is installed so tests do not hit assertions.
|
|
21
|
+
/// </summary>
|
|
22
|
+
[SetUp]
|
|
23
|
+
public virtual void BaseSetUp()
|
|
24
|
+
{
|
|
25
|
+
#if REFLEX_PRESENT
|
|
26
|
+
ReflexTestSupport.EnsureReflexSettings();
|
|
27
|
+
#endif
|
|
28
|
+
}
|
|
29
|
+
|
|
19
30
|
// Per-test tracked UnityEngine.Objects
|
|
20
31
|
protected readonly List<Object> _trackedObjects = new();
|
|
21
32
|
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
#if REFLEX_PRESENT
|
|
2
|
+
namespace WallstopStudios.UnityHelpers.Tests.TestUtils
|
|
3
|
+
{
|
|
4
|
+
using System;
|
|
5
|
+
using System.Collections.Generic;
|
|
6
|
+
using System.Linq;
|
|
7
|
+
using System.Reflection;
|
|
8
|
+
using UnityEngine;
|
|
9
|
+
|
|
10
|
+
public static class ReflexTestSupport
|
|
11
|
+
{
|
|
12
|
+
private const string ReflexSettingsTypeName = "Reflex.Configuration.ReflexSettings";
|
|
13
|
+
private const string InstanceFieldName = "_instance";
|
|
14
|
+
private const string LogLevelBackingFieldName = "<LogLevel>k__BackingField";
|
|
15
|
+
private const string ProjectScopesBackingFieldName = "<ProjectScopes>k__BackingField";
|
|
16
|
+
private const string LogLevelTypeName = "Reflex.Logging.LogLevel";
|
|
17
|
+
private const string ProjectScopeTypeName = "Reflex.Core.ProjectScope";
|
|
18
|
+
|
|
19
|
+
private static bool _initialized;
|
|
20
|
+
|
|
21
|
+
public static void EnsureReflexSettings()
|
|
22
|
+
{
|
|
23
|
+
if (_initialized)
|
|
24
|
+
{
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
Type settingsType = FindType(ReflexSettingsTypeName);
|
|
29
|
+
if (settingsType == null)
|
|
30
|
+
{
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
FieldInfo instanceField = settingsType.GetField(
|
|
35
|
+
InstanceFieldName,
|
|
36
|
+
BindingFlags.NonPublic | BindingFlags.Static
|
|
37
|
+
);
|
|
38
|
+
if (instanceField == null)
|
|
39
|
+
{
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
object currentInstance = instanceField.GetValue(null);
|
|
44
|
+
if (currentInstance == null)
|
|
45
|
+
{
|
|
46
|
+
ScriptableObject settings = ScriptableObject.CreateInstance(settingsType);
|
|
47
|
+
SetInstanceField(
|
|
48
|
+
settingsType,
|
|
49
|
+
settings,
|
|
50
|
+
LogLevelBackingFieldName,
|
|
51
|
+
GetLogLevelInfo()
|
|
52
|
+
);
|
|
53
|
+
SetInstanceField(
|
|
54
|
+
settingsType,
|
|
55
|
+
settings,
|
|
56
|
+
ProjectScopesBackingFieldName,
|
|
57
|
+
CreateEmptyProjectScopesList()
|
|
58
|
+
);
|
|
59
|
+
instanceField.SetValue(null, settings);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
_initialized = true;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
private static void SetInstanceField(
|
|
66
|
+
Type declaringType,
|
|
67
|
+
object instance,
|
|
68
|
+
string fieldName,
|
|
69
|
+
object value
|
|
70
|
+
)
|
|
71
|
+
{
|
|
72
|
+
FieldInfo field = declaringType.GetField(
|
|
73
|
+
fieldName,
|
|
74
|
+
BindingFlags.Instance | BindingFlags.NonPublic
|
|
75
|
+
);
|
|
76
|
+
field?.SetValue(instance, value);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
private static object GetLogLevelInfo()
|
|
80
|
+
{
|
|
81
|
+
Type logLevelType = FindType(LogLevelTypeName);
|
|
82
|
+
if (logLevelType == null)
|
|
83
|
+
{
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return Enum.Parse(logLevelType, "Info", ignoreCase: true);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
private static object CreateEmptyProjectScopesList()
|
|
91
|
+
{
|
|
92
|
+
Type projectScopeType = FindType(ProjectScopeTypeName);
|
|
93
|
+
if (projectScopeType == null)
|
|
94
|
+
{
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
Type listType = typeof(List<>).MakeGenericType(projectScopeType);
|
|
99
|
+
return Activator.CreateInstance(listType);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
private static Type FindType(string fullName)
|
|
103
|
+
{
|
|
104
|
+
return AppDomain
|
|
105
|
+
.CurrentDomain.GetAssemblies()
|
|
106
|
+
.Select(assembly => assembly.GetType(fullName))
|
|
107
|
+
.FirstOrDefault(type => type != null);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
#endif
|
|
@@ -26,10 +26,10 @@ namespace WallstopStudios.UnityHelpers.Tests.Utils
|
|
|
26
26
|
// Define a physics shape for the sprite (a simple rectangle)
|
|
27
27
|
Vector2[] physicsShape =
|
|
28
28
|
{
|
|
29
|
-
new
|
|
30
|
-
new
|
|
31
|
-
new
|
|
32
|
-
new
|
|
29
|
+
new(-0.5f, -0.5f),
|
|
30
|
+
new(-0.5f, 0.5f),
|
|
31
|
+
new(0.5f, 0.5f),
|
|
32
|
+
new(0.5f, -0.5f),
|
|
33
33
|
};
|
|
34
34
|
_testSprite.OverridePhysicsShape(new[] { physicsShape });
|
|
35
35
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "com.wallstop-studios.unity-helpers",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"displayName": "Unity Helpers",
|
|
5
5
|
"description": "Various Unity Helper Library",
|
|
6
6
|
"dependencies": {},
|
|
@@ -43,6 +43,11 @@
|
|
|
43
43
|
"description": "SceneContext installer, scene-wide assignment, and prefab instantiation with relations.",
|
|
44
44
|
"path": "Samples~/DI - Zenject"
|
|
45
45
|
},
|
|
46
|
+
{
|
|
47
|
+
"displayName": "DI – Reflex",
|
|
48
|
+
"description": "SceneScope installer, scene scan, and runtime Container helpers.",
|
|
49
|
+
"path": "Samples~/DI - Reflex"
|
|
50
|
+
},
|
|
46
51
|
{
|
|
47
52
|
"displayName": "Relational Components – Basic",
|
|
48
53
|
"description": "Attribute-based auto-wiring without DI; parent/sibling/child examples.",
|