com.wallstop-studios.unity-helpers 2.0.0 → 2.0.2
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/Helper/Logging/UnityLogTagFormatter.cs +76 -90
- 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/Extensions/UnityLogTagFormatterEdgeTests.cs +84 -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
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
namespace Samples.UnityHelpers.DI.Reflex
|
|
2
|
+
{
|
|
3
|
+
using Reflex.Core;
|
|
4
|
+
using Reflex.Extensions;
|
|
5
|
+
using UnityEngine;
|
|
6
|
+
using WallstopStudios.UnityHelpers.Integrations.Reflex;
|
|
7
|
+
|
|
8
|
+
/// <summary>
|
|
9
|
+
/// Demonstrates the Reflex container helpers for instantiation and relational assignment.
|
|
10
|
+
/// </summary>
|
|
11
|
+
public sealed class ReflexSpawner : MonoBehaviour
|
|
12
|
+
{
|
|
13
|
+
[SerializeField]
|
|
14
|
+
private ReflexRelationalConsumer _componentPrefab;
|
|
15
|
+
|
|
16
|
+
[SerializeField]
|
|
17
|
+
private GameObject _hierarchyPrefab;
|
|
18
|
+
|
|
19
|
+
[SerializeField]
|
|
20
|
+
private Transform _defaultParent;
|
|
21
|
+
|
|
22
|
+
private Container _sceneContainer;
|
|
23
|
+
|
|
24
|
+
private void Awake()
|
|
25
|
+
{
|
|
26
|
+
_sceneContainer = gameObject.scene.GetSceneContainer();
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/// <summary>
|
|
30
|
+
/// Instantiate a component prefab through Reflex so dependencies and relational fields are ready.
|
|
31
|
+
/// </summary>
|
|
32
|
+
public ReflexRelationalConsumer SpawnComponent(Transform parent)
|
|
33
|
+
{
|
|
34
|
+
if (_sceneContainer == null || _componentPrefab == null)
|
|
35
|
+
{
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
Transform targetParent = parent != null ? parent : _defaultParent;
|
|
40
|
+
ReflexRelationalConsumer instance = _sceneContainer.InstantiateComponentWithRelations(
|
|
41
|
+
_componentPrefab,
|
|
42
|
+
targetParent
|
|
43
|
+
);
|
|
44
|
+
return instance;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/// <summary>
|
|
48
|
+
/// Instantiate a hierarchy prefab and hydrate the entire tree.
|
|
49
|
+
/// </summary>
|
|
50
|
+
public GameObject SpawnHierarchy(Transform parent)
|
|
51
|
+
{
|
|
52
|
+
if (_sceneContainer == null || _hierarchyPrefab == null)
|
|
53
|
+
{
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
Transform targetParent = parent != null ? parent : _defaultParent;
|
|
58
|
+
GameObject root = _sceneContainer.InstantiateGameObjectWithRelations(
|
|
59
|
+
_hierarchyPrefab,
|
|
60
|
+
targetParent,
|
|
61
|
+
includeInactiveChildren: true
|
|
62
|
+
);
|
|
63
|
+
return root;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/// <summary>
|
|
67
|
+
/// Hydrate a GameObject that was spawned outside of Reflex.
|
|
68
|
+
/// </summary>
|
|
69
|
+
public void HydrateExistingHierarchy(GameObject root, bool includeInactiveChildren)
|
|
70
|
+
{
|
|
71
|
+
if (_sceneContainer == null || root == null)
|
|
72
|
+
{
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
_sceneContainer.InjectGameObjectWithRelations(root, includeInactiveChildren);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "Samples.UnityHelpers.DI.Reflex",
|
|
3
|
+
"rootNamespace": "Samples.UnityHelpers.DI.Reflex",
|
|
4
|
+
"references": [
|
|
5
|
+
"WallstopStudios.UnityHelpers",
|
|
6
|
+
"WallstopStudios.UnityHelpers.Integration.Reflex",
|
|
7
|
+
"Reflex"
|
|
8
|
+
],
|
|
9
|
+
"includePlatforms": [],
|
|
10
|
+
"excludePlatforms": [],
|
|
11
|
+
"allowUnsafeCode": false,
|
|
12
|
+
"overrideReferences": false,
|
|
13
|
+
"precompiledReferences": [],
|
|
14
|
+
"autoReferenced": true,
|
|
15
|
+
"defineConstraints": [
|
|
16
|
+
"REFLEX_PRESENT"
|
|
17
|
+
],
|
|
18
|
+
"versionDefines": [
|
|
19
|
+
{
|
|
20
|
+
"name": "com.gustavopsantos.reflex",
|
|
21
|
+
"expression": "0.0.1",
|
|
22
|
+
"define": "REFLEX_PRESENT"
|
|
23
|
+
}
|
|
24
|
+
],
|
|
25
|
+
"noEngineReferences": false
|
|
26
|
+
}
|
|
@@ -485,8 +485,8 @@ Only call `AssignRelationalComponents()` manually if you're not using the DI int
|
|
|
485
485
|
|
|
486
486
|
**Unity Helpers Documentation:**
|
|
487
487
|
|
|
488
|
-
- [Relational Components Guide](../../RELATIONAL_COMPONENTS.md) - Complete attribute reference and recipes
|
|
489
|
-
- [Getting Started](../../GETTING_STARTED.md) - Unity Helpers quick start guide
|
|
488
|
+
- [Relational Components Guide](../../Docs/RELATIONAL_COMPONENTS.md) - Complete attribute reference and recipes
|
|
489
|
+
- [Getting Started](../../Docs/GETTING_STARTED.md) - Unity Helpers quick start guide
|
|
490
490
|
- [Main README](../../README.md) - Full feature overview
|
|
491
491
|
|
|
492
492
|
**VContainer Documentation:**
|
|
@@ -496,8 +496,8 @@ Only call `AssignRelationalComponents()` manually if you're not using the DI int
|
|
|
496
496
|
|
|
497
497
|
**Troubleshooting:**
|
|
498
498
|
|
|
499
|
-
- [Relational Components Troubleshooting](../../RELATIONAL_COMPONENTS.md#troubleshooting) - Detailed solutions
|
|
500
|
-
- [DI Integration Testing Guide](../../RELATIONAL_COMPONENTS.md#di-integrations-testing-and-edge-cases) - Advanced scenarios
|
|
499
|
+
- [Relational Components Troubleshooting](../../Docs/RELATIONAL_COMPONENTS.md#troubleshooting) - Detailed solutions
|
|
500
|
+
- [DI Integration Testing Guide](../../Docs/RELATIONAL_COMPONENTS.md#di-integrations-testing-and-edge-cases) - Advanced scenarios
|
|
501
501
|
|
|
502
502
|
---
|
|
503
503
|
|
|
@@ -506,10 +506,11 @@ Only call `AssignRelationalComponents()` manually if you're not using the DI int
|
|
|
506
506
|
1. **Try the sample scene:** Open `VContainer_Sample.unity` and press Play
|
|
507
507
|
2. **Read the scripts:** See how `GameLifetimeScope` and `Spawner` work
|
|
508
508
|
3. **Add to your project:** Copy the pattern to your own LifetimeScope
|
|
509
|
-
4. **Explore attributes:** Check out the [Relational Components Guide](../../RELATIONAL_COMPONENTS.md) for all options
|
|
509
|
+
4. **Explore attributes:** Check out the [Relational Components Guide](../../Docs/RELATIONAL_COMPONENTS.md) for all options
|
|
510
510
|
|
|
511
511
|
---
|
|
512
512
|
|
|
513
513
|
## Made with ❤️ by Wallstop Studios
|
|
514
514
|
|
|
515
515
|
*Unity Helpers is production-ready and actively maintained. [Star the repo](https://github.com/wallstop/unity-helpers) if you find it useful!*
|
|
516
|
+
|
|
@@ -507,8 +507,8 @@ Unity Helpers automatically detects which one you're using.
|
|
|
507
507
|
|
|
508
508
|
**Unity Helpers Documentation:**
|
|
509
509
|
|
|
510
|
-
- [Relational Components Guide](../../RELATIONAL_COMPONENTS.md) - Complete attribute reference and recipes
|
|
511
|
-
- [Getting Started](../../GETTING_STARTED.md) - Unity Helpers quick start guide
|
|
510
|
+
- [Relational Components Guide](../../Docs/RELATIONAL_COMPONENTS.md) - Complete attribute reference and recipes
|
|
511
|
+
- [Getting Started](../../Docs/GETTING_STARTED.md) - Unity Helpers quick start guide
|
|
512
512
|
- [Main README](../../README.md) - Full feature overview
|
|
513
513
|
|
|
514
514
|
**Zenject Documentation:**
|
|
@@ -518,8 +518,8 @@ Unity Helpers automatically detects which one you're using.
|
|
|
518
518
|
|
|
519
519
|
**Troubleshooting:**
|
|
520
520
|
|
|
521
|
-
- [Relational Components Troubleshooting](../../RELATIONAL_COMPONENTS.md#troubleshooting) - Detailed solutions
|
|
522
|
-
- [DI Integration Testing Guide](../../RELATIONAL_COMPONENTS.md#di-integrations-testing-and-edge-cases) - Advanced scenarios
|
|
521
|
+
- [Relational Components Troubleshooting](../../Docs/RELATIONAL_COMPONENTS.md#troubleshooting) - Detailed solutions
|
|
522
|
+
- [DI Integration Testing Guide](../../Docs/RELATIONAL_COMPONENTS.md#di-integrations-testing-and-edge-cases) - Advanced scenarios
|
|
523
523
|
|
|
524
524
|
---
|
|
525
525
|
|
|
@@ -528,7 +528,7 @@ Unity Helpers automatically detects which one you're using.
|
|
|
528
528
|
1. **Try the sample scene:** Open `Zenject_Sample.unity` and press Play
|
|
529
529
|
2. **Read the scripts:** See how `SpawnerZenject` and `RelationalConsumer` work
|
|
530
530
|
3. **Add to your project:** Add `RelationalComponentsInstaller` to your `SceneContext`
|
|
531
|
-
4. **Explore attributes:** Check out the [Relational Components Guide](../../RELATIONAL_COMPONENTS.md) for all options
|
|
531
|
+
4. **Explore attributes:** Check out the [Relational Components Guide](../../Docs/RELATIONAL_COMPONENTS.md) for all options
|
|
532
532
|
|
|
533
533
|
---
|
|
534
534
|
|
|
@@ -551,3 +551,4 @@ Both integrations provide the same relational component features - choose based
|
|
|
551
551
|
## Made with ❤️ by Wallstop Studios
|
|
552
552
|
|
|
553
553
|
*Unity Helpers is production-ready and actively maintained. [Star the repo](https://github.com/wallstop/unity-helpers) if you find it useful!*
|
|
554
|
+
|
|
@@ -28,20 +28,19 @@ namespace WallstopStudios.UnityHelpers.Tests.Core.Attributes
|
|
|
28
28
|
{
|
|
29
29
|
AttributeMetadataCache cache = CreateScriptableObject<AttributeMetadataCache>();
|
|
30
30
|
|
|
31
|
-
AttributeMetadataCache.RelationalTypeMetadata relationalMetadata =
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
);
|
|
31
|
+
AttributeMetadataCache.RelationalTypeMetadata relationalMetadata = new(
|
|
32
|
+
typeof(RelationalConsumer).AssemblyQualifiedName,
|
|
33
|
+
new[]
|
|
34
|
+
{
|
|
35
|
+
new AttributeMetadataCache.RelationalFieldMetadata(
|
|
36
|
+
"_spriteRenderer",
|
|
37
|
+
AttributeMetadataCache.RelationalAttributeKind.Sibling,
|
|
38
|
+
AttributeMetadataCache.FieldKind.Single,
|
|
39
|
+
typeof(SpriteRenderer).AssemblyQualifiedName,
|
|
40
|
+
false
|
|
41
|
+
),
|
|
42
|
+
}
|
|
43
|
+
);
|
|
45
44
|
|
|
46
45
|
cache.SetMetadata(
|
|
47
46
|
System.Array.Empty<string>(),
|
|
@@ -50,7 +49,7 @@ namespace WallstopStudios.UnityHelpers.Tests.Core.Attributes
|
|
|
50
49
|
);
|
|
51
50
|
cache.ForceRebuildForTests();
|
|
52
51
|
|
|
53
|
-
RelationalComponentAssigner assigner = new
|
|
52
|
+
RelationalComponentAssigner assigner = new(cache);
|
|
54
53
|
|
|
55
54
|
Assert.IsTrue(
|
|
56
55
|
assigner.HasRelationalAssignments(typeof(RelationalConsumer)),
|
|
@@ -67,20 +66,19 @@ namespace WallstopStudios.UnityHelpers.Tests.Core.Attributes
|
|
|
67
66
|
{
|
|
68
67
|
AttributeMetadataCache cache = CreateScriptableObject<AttributeMetadataCache>();
|
|
69
68
|
|
|
70
|
-
AttributeMetadataCache.RelationalTypeMetadata relationalMetadata =
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
);
|
|
69
|
+
AttributeMetadataCache.RelationalTypeMetadata relationalMetadata = new(
|
|
70
|
+
typeof(RelationalConsumer).AssemblyQualifiedName,
|
|
71
|
+
new[]
|
|
72
|
+
{
|
|
73
|
+
new AttributeMetadataCache.RelationalFieldMetadata(
|
|
74
|
+
"_spriteRenderer",
|
|
75
|
+
AttributeMetadataCache.RelationalAttributeKind.Sibling,
|
|
76
|
+
AttributeMetadataCache.FieldKind.Single,
|
|
77
|
+
typeof(SpriteRenderer).AssemblyQualifiedName,
|
|
78
|
+
false
|
|
79
|
+
),
|
|
80
|
+
}
|
|
81
|
+
);
|
|
84
82
|
|
|
85
83
|
cache.SetMetadata(
|
|
86
84
|
System.Array.Empty<string>(),
|
|
@@ -89,7 +87,7 @@ namespace WallstopStudios.UnityHelpers.Tests.Core.Attributes
|
|
|
89
87
|
);
|
|
90
88
|
cache.ForceRebuildForTests();
|
|
91
89
|
|
|
92
|
-
RelationalComponentAssigner assigner = new
|
|
90
|
+
RelationalComponentAssigner assigner = new(cache);
|
|
93
91
|
|
|
94
92
|
GameObject go1 = NewGameObject("Relational");
|
|
95
93
|
SpriteRenderer sr1 = go1.AddComponent<SpriteRenderer>();
|
|
@@ -100,7 +98,7 @@ namespace WallstopStudios.UnityHelpers.Tests.Core.Attributes
|
|
|
100
98
|
|
|
101
99
|
Assert.IsTrue(consumer.SR == null, "Precondition: relational field should start null");
|
|
102
100
|
|
|
103
|
-
List<Component> items = new
|
|
101
|
+
List<Component> items = new() { consumer, null, non.transform };
|
|
104
102
|
assigner.Assign(items);
|
|
105
103
|
|
|
106
104
|
Assert.IsTrue(
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
#if REFLEX_PRESENT
|
|
2
|
+
namespace WallstopStudios.UnityHelpers.Tests.Integrations.Reflex
|
|
3
|
+
{
|
|
4
|
+
using System.Reflection;
|
|
5
|
+
using NUnit.Framework;
|
|
6
|
+
using WallstopStudios.UnityHelpers.Integrations.Reflex;
|
|
7
|
+
|
|
8
|
+
public sealed class ReflexIntegrationCompilationTests
|
|
9
|
+
{
|
|
10
|
+
[Test]
|
|
11
|
+
public void CanReferenceReflexIntegrationTypes()
|
|
12
|
+
{
|
|
13
|
+
Assert.NotNull(
|
|
14
|
+
typeof(RelationalComponentsInstaller),
|
|
15
|
+
"RelationalComponentsInstaller should be available when REFLEX_PRESENT is defined."
|
|
16
|
+
);
|
|
17
|
+
Assert.NotNull(
|
|
18
|
+
typeof(ContainerRelationalExtensions),
|
|
19
|
+
"ContainerRelationalExtensions should be available when REFLEX_PRESENT is defined."
|
|
20
|
+
);
|
|
21
|
+
Assert.NotNull(
|
|
22
|
+
typeof(RelationalSceneAssignmentOptions),
|
|
23
|
+
"RelationalSceneAssignmentOptions should be available when REFLEX_PRESENT is defined."
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
[Test]
|
|
28
|
+
public void PublicExtensionMethodsAccessible()
|
|
29
|
+
{
|
|
30
|
+
MethodInfo method = typeof(ContainerRelationalExtensions).GetMethod(
|
|
31
|
+
"AssignRelationalComponents",
|
|
32
|
+
BindingFlags.Public | BindingFlags.Static
|
|
33
|
+
);
|
|
34
|
+
Assert.NotNull(
|
|
35
|
+
method,
|
|
36
|
+
"AssignRelationalComponents extension method should be discoverable."
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
#endif
|
package/Tests/Editor/Integrations/Reflex/WallstopStudios.UnityHelpers.Tests.Editor.Reflex.asmdef
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "WallstopStudios.UnityHelpers.Tests.Editor.Reflex",
|
|
3
|
+
"rootNamespace": "WallstopStudios.UnityHelpers.Tests.Integrations.Reflex",
|
|
4
|
+
"references": [
|
|
5
|
+
"UnityEditor.TestRunner",
|
|
6
|
+
"UnityEngine.TestRunner",
|
|
7
|
+
"WallstopStudios.UnityHelpers",
|
|
8
|
+
"WallstopStudios.UnityHelpers.Integration.Reflex",
|
|
9
|
+
"WallstopStudios.UnityHelpers.Tests.Editor",
|
|
10
|
+
"Reflex"
|
|
11
|
+
],
|
|
12
|
+
"includePlatforms": ["Editor"],
|
|
13
|
+
"excludePlatforms": [],
|
|
14
|
+
"allowUnsafeCode": false,
|
|
15
|
+
"overrideReferences": true,
|
|
16
|
+
"precompiledReferences": ["nunit.framework.dll"],
|
|
17
|
+
"autoReferenced": false,
|
|
18
|
+
"defineConstraints": ["UNITY_INCLUDE_TESTS", "REFLEX_PRESENT"],
|
|
19
|
+
"versionDefines": [
|
|
20
|
+
{
|
|
21
|
+
"name": "com.gustavopsantos.reflex",
|
|
22
|
+
"expression": "0.0.1",
|
|
23
|
+
"define": "REFLEX_PRESENT"
|
|
24
|
+
}
|
|
25
|
+
],
|
|
26
|
+
"noEngineReferences": false
|
|
27
|
+
}
|
|
@@ -34,20 +34,19 @@ namespace WallstopStudios.UnityHelpers.Tests.Integrations.VContainer
|
|
|
34
34
|
|
|
35
35
|
AttributeMetadataCache cache = CreateScriptableObject<AttributeMetadataCache>();
|
|
36
36
|
#if UNITY_EDITOR
|
|
37
|
-
AttributeMetadataCache.RelationalTypeMetadata relationalMetadata =
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
);
|
|
37
|
+
AttributeMetadataCache.RelationalTypeMetadata relationalMetadata = new(
|
|
38
|
+
typeof(Consumer).AssemblyQualifiedName,
|
|
39
|
+
new[]
|
|
40
|
+
{
|
|
41
|
+
new AttributeMetadataCache.RelationalFieldMetadata(
|
|
42
|
+
"_spriteRenderer",
|
|
43
|
+
AttributeMetadataCache.RelationalAttributeKind.Sibling,
|
|
44
|
+
AttributeMetadataCache.FieldKind.Single,
|
|
45
|
+
typeof(SpriteRenderer).AssemblyQualifiedName,
|
|
46
|
+
false
|
|
47
|
+
),
|
|
48
|
+
}
|
|
49
|
+
);
|
|
51
50
|
|
|
52
51
|
cache.SetMetadata(
|
|
53
52
|
System.Array.Empty<string>(),
|
|
@@ -58,8 +57,8 @@ namespace WallstopStudios.UnityHelpers.Tests.Integrations.VContainer
|
|
|
58
57
|
yield return null;
|
|
59
58
|
#endif
|
|
60
59
|
|
|
61
|
-
RelationalComponentAssigner assigner = new
|
|
62
|
-
RelationalComponentEntryPoint entry = new
|
|
60
|
+
RelationalComponentAssigner assigner = new(cache);
|
|
61
|
+
RelationalComponentEntryPoint entry = new(
|
|
63
62
|
assigner,
|
|
64
63
|
cache,
|
|
65
64
|
RelationalSceneAssignmentOptions.Default
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
#if VCONTAINER_PRESENT
|
|
2
2
|
namespace WallstopStudios.UnityHelpers.Tests.Integrations.VContainer
|
|
3
3
|
{
|
|
4
|
-
using System.Collections;
|
|
5
4
|
using global::VContainer;
|
|
6
5
|
using NUnit.Framework;
|
|
7
6
|
using UnityEngine;
|
|
8
|
-
using UnityEngine.SceneManagement;
|
|
9
|
-
using UnityEngine.TestTools;
|
|
10
7
|
using WallstopStudios.UnityHelpers.Core.Attributes;
|
|
11
8
|
using WallstopStudios.UnityHelpers.Integrations.VContainer;
|
|
12
9
|
using WallstopStudios.UnityHelpers.Tags;
|
|
@@ -26,7 +23,7 @@ namespace WallstopStudios.UnityHelpers.Tests.Integrations.VContainer
|
|
|
26
23
|
[Test]
|
|
27
24
|
public void InjectWithRelationsAssignsFields()
|
|
28
25
|
{
|
|
29
|
-
ContainerBuilder builder = new
|
|
26
|
+
ContainerBuilder builder = new();
|
|
30
27
|
IObjectResolver resolver = builder.Build();
|
|
31
28
|
|
|
32
29
|
// Build hierarchy: Parent(Rigidbody) -> Middle(TestComponent) -> Child(CapsuleCollider)
|
|
@@ -49,7 +46,7 @@ namespace WallstopStudios.UnityHelpers.Tests.Integrations.VContainer
|
|
|
49
46
|
[Test]
|
|
50
47
|
public void InstantiateComponentWithRelationsAssignsFields()
|
|
51
48
|
{
|
|
52
|
-
ContainerBuilder builder = new
|
|
49
|
+
ContainerBuilder builder = new();
|
|
53
50
|
IObjectResolver resolver = builder.Build();
|
|
54
51
|
|
|
55
52
|
// Build prefab hierarchy: Root(Rigidbody) -> Middle(TestComponent) -> Child(CapsuleCollider)
|
|
@@ -74,7 +71,7 @@ namespace WallstopStudios.UnityHelpers.Tests.Integrations.VContainer
|
|
|
74
71
|
[Test]
|
|
75
72
|
public void InjectGameObjectWithRelationsAssignsHierarchy()
|
|
76
73
|
{
|
|
77
|
-
ContainerBuilder builder = new
|
|
74
|
+
ContainerBuilder builder = new();
|
|
78
75
|
IObjectResolver resolver = builder.Build();
|
|
79
76
|
|
|
80
77
|
GameObject root = NewGameObject("Root");
|
|
@@ -95,7 +92,7 @@ namespace WallstopStudios.UnityHelpers.Tests.Integrations.VContainer
|
|
|
95
92
|
[Test]
|
|
96
93
|
public void InstantiateGameObjectWithRelationsAssignsHierarchy()
|
|
97
94
|
{
|
|
98
|
-
ContainerBuilder builder = new
|
|
95
|
+
ContainerBuilder builder = new();
|
|
99
96
|
IObjectResolver resolver = builder.Build();
|
|
100
97
|
|
|
101
98
|
GameObject prefab = NewGameObject("PrefabRoot");
|
|
@@ -122,7 +119,7 @@ namespace WallstopStudios.UnityHelpers.Tests.Integrations.VContainer
|
|
|
122
119
|
|
|
123
120
|
AttributeMetadataCache.RelationalFieldMetadata[] fields =
|
|
124
121
|
{
|
|
125
|
-
new
|
|
122
|
+
new(
|
|
126
123
|
nameof(BaseWithSibling._spriteRenderer),
|
|
127
124
|
AttributeMetadataCache.RelationalAttributeKind.Sibling,
|
|
128
125
|
AttributeMetadataCache.FieldKind.Single,
|
|
@@ -132,15 +129,12 @@ namespace WallstopStudios.UnityHelpers.Tests.Integrations.VContainer
|
|
|
132
129
|
};
|
|
133
130
|
AttributeMetadataCache.RelationalTypeMetadata[] relational =
|
|
134
131
|
{
|
|
135
|
-
new
|
|
136
|
-
typeof(BaseWithSibling).AssemblyQualifiedName,
|
|
137
|
-
fields
|
|
138
|
-
),
|
|
132
|
+
new(typeof(BaseWithSibling).AssemblyQualifiedName, fields),
|
|
139
133
|
};
|
|
140
134
|
cache._relationalTypeMetadata = relational;
|
|
141
135
|
cache.ForceRebuildForTests();
|
|
142
136
|
|
|
143
|
-
ContainerBuilder builder = new
|
|
137
|
+
ContainerBuilder builder = new();
|
|
144
138
|
builder.RegisterInstance(cache).AsSelf();
|
|
145
139
|
builder
|
|
146
140
|
.RegisterInstance(new RelationalComponentAssigner(cache))
|
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
#if ZENJECT_PRESENT
|
|
2
2
|
namespace WallstopStudios.UnityHelpers.Tests.Integrations.Zenject
|
|
3
3
|
{
|
|
4
|
-
using System.Collections;
|
|
5
4
|
using global::Zenject;
|
|
6
5
|
using NUnit.Framework;
|
|
7
6
|
using UnityEngine;
|
|
8
|
-
using UnityEngine.SceneManagement;
|
|
9
|
-
using UnityEngine.TestTools;
|
|
10
7
|
using WallstopStudios.UnityHelpers.Core.Attributes;
|
|
11
8
|
using WallstopStudios.UnityHelpers.Integrations.Zenject;
|
|
12
|
-
using WallstopStudios.UnityHelpers.Tags;
|
|
13
9
|
using WallstopStudios.UnityHelpers.Tests.Editor.Utils;
|
|
14
10
|
|
|
15
11
|
public sealed class ZenjectRelationalHelpersTests : CommonTestBase
|
|
@@ -26,7 +22,7 @@ namespace WallstopStudios.UnityHelpers.Tests.Integrations.Zenject
|
|
|
26
22
|
[Test]
|
|
27
23
|
public void InjectWithRelationsAssignsFields()
|
|
28
24
|
{
|
|
29
|
-
DiContainer container = new
|
|
25
|
+
DiContainer container = new();
|
|
30
26
|
|
|
31
27
|
// Build hierarchy: Parent(Rigidbody) -> Middle(TestComponent) -> Child(CapsuleCollider)
|
|
32
28
|
GameObject parent = NewGameObject("Root");
|
|
@@ -47,7 +43,7 @@ namespace WallstopStudios.UnityHelpers.Tests.Integrations.Zenject
|
|
|
47
43
|
[Test]
|
|
48
44
|
public void InjectGameObjectWithRelationsAssignsHierarchy()
|
|
49
45
|
{
|
|
50
|
-
DiContainer container = new
|
|
46
|
+
DiContainer container = new();
|
|
51
47
|
|
|
52
48
|
GameObject root = NewGameObject("Root");
|
|
53
49
|
root.AddComponent<Rigidbody>();
|
|
@@ -67,13 +63,13 @@ namespace WallstopStudios.UnityHelpers.Tests.Integrations.Zenject
|
|
|
67
63
|
[Test]
|
|
68
64
|
public void InstantiateGameObjectWithRelationsAssignsHierarchy()
|
|
69
65
|
{
|
|
70
|
-
DiContainer container = new
|
|
66
|
+
DiContainer container = new();
|
|
71
67
|
|
|
72
68
|
GameObject prefab = NewGameObject("PrefabRoot");
|
|
73
69
|
prefab.AddComponent<Rigidbody>();
|
|
74
70
|
GameObject mid = NewGameObject("PrefabMiddle");
|
|
75
71
|
mid.transform.SetParent(prefab.transform);
|
|
76
|
-
|
|
72
|
+
_ = mid.AddComponent<TestComponent>();
|
|
77
73
|
GameObject child = NewGameObject("PrefabChild");
|
|
78
74
|
child.transform.SetParent(mid.transform);
|
|
79
75
|
child.AddComponent<CapsuleCollider>();
|
|
@@ -90,8 +86,8 @@ namespace WallstopStudios.UnityHelpers.Tests.Integrations.Zenject
|
|
|
90
86
|
public void RelationalMemoryPoolAssignsOnSpawn()
|
|
91
87
|
{
|
|
92
88
|
// Create a pool and inject a container into the private field using reflection
|
|
93
|
-
RelationalMemoryPool<TestComponent> pool = new
|
|
94
|
-
DiContainer container = new
|
|
89
|
+
RelationalMemoryPool<TestComponent> pool = new();
|
|
90
|
+
DiContainer container = new();
|
|
95
91
|
|
|
96
92
|
pool._container = container;
|
|
97
93
|
|
|
@@ -105,7 +101,7 @@ namespace WallstopStudios.UnityHelpers.Tests.Integrations.Zenject
|
|
|
105
101
|
child.AddComponent<CapsuleCollider>();
|
|
106
102
|
|
|
107
103
|
// Call OnSpawned indirectly via protected method using a small helper
|
|
108
|
-
PoolHarness harness = new
|
|
104
|
+
PoolHarness harness = new(pool);
|
|
109
105
|
harness.InvokeOnSpawned(comp);
|
|
110
106
|
|
|
111
107
|
Assert.IsTrue(comp.parentBody != null);
|