com.wallstop-studios.unity-helpers 2.0.0-rc81.9 → 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/.editorconfig +1 -1
- package/.gitattributes +1 -1
- package/.githooks/pre-commit +31 -5
- package/.githooks/pre-push +50 -0
- package/.github/dependabot.yml +24 -2
- package/.github/scripts/check-markdown-links.ps1 +77 -0
- package/.github/scripts/check_markdown_links.py +89 -0
- package/.github/scripts/check_markdown_url_encoding.py +74 -0
- package/.github/scripts/validate_markdown_links.py +194 -0
- package/.github/workflows/csharpier-autofix.yml +152 -0
- package/.github/workflows/format-on-demand.yml +305 -0
- package/.github/workflows/lint-doc-links.yml +8 -5
- package/.github/workflows/markdown-json.yml +6 -2
- package/.github/workflows/npm-publish.yml +1 -1
- package/.github/workflows/prettier-autofix.yml +195 -0
- package/.github/workflows/update-dotnet-tools.yml +80 -0
- package/.github/workflows/yaml-format-lint.yml +41 -0
- package/.lychee.toml +4 -4
- package/.markdownlint.jsonc +21 -0
- package/.pre-commit-config.yaml +11 -3
- package/.yamllint.yaml +31 -0
- package/AGENTS.md +5 -1
- package/Docs/CHANGELOG.md +11 -0
- package/Docs/CONTRIBUTING.md +49 -0
- package/Docs/CONTRIBUTING.md.meta +7 -0
- package/{EDITOR_TOOLS_GUIDE.md → Docs/EDITOR_TOOLS_GUIDE.md} +4 -0
- 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} +50 -64
- 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} +111 -84
- package/{SERIALIZATION.md → Docs/SERIALIZATION.md} +15 -0
- 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/Docs/SPATIAL_TREE_2D_PERFORMANCE.md +241 -0
- package/Docs/SPATIAL_TREE_3D_PERFORMANCE.md +243 -0
- package/{THIRD_PARTY_NOTICES.md → Docs/THIRD_PARTY_NOTICES.md} +1 -1
- 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/AnimationEventEditor.cs +337 -160
- package/Editor/Core/Helper/AnimationEventHelpers.cs +178 -152
- package/Editor/CustomEditors/PersistentDirectoryGUI.cs +20 -11
- package/Editor/CustomEditors/TexturePlatformOverrideEntryDrawer.cs +11 -2
- package/Editor/FitTextureSizeWindow.cs +43 -19
- package/Editor/PersistentDirectorySettings.cs +64 -12
- package/Editor/PrefabChecker.cs +72 -5
- package/Editor/Sprites/AnimationCopier.cs +131 -55
- package/Editor/Sprites/AnimationCreator.cs +63 -22
- package/Editor/Sprites/AnimationViewerWindow.cs +42 -6
- package/Editor/Sprites/TexturePlatformNameHelper.cs +50 -39
- package/Editor/Sprites/TextureResizerWizard.cs +23 -1
- package/Editor/Sprites/TextureSettingsApplierWindow.cs +148 -85
- package/Editor/Tools/ImageBlurTool.cs +81 -10
- package/Editor/Utils/EditorUi.cs +1 -1
- package/Editor/Utils/ScriptableObjectSingletonCreator.cs +1 -1
- package/README.md +428 -2433
- package/Runtime/AssemblyInfo.cs +4 -0
- package/Runtime/Core/Attributes/NotNullAttribute.cs +1 -3
- package/Runtime/Core/Attributes/RelationalComponentAssigner.cs +50 -5
- package/Runtime/Core/DataStructure/CyclicBuffer.cs +0 -1
- 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/Extension/RandomExtensions.cs +68 -0
- package/Runtime/Core/Extension/WallstopStudiosLogger.cs +16 -0
- package/Runtime/Core/Helper/Partials/ObjectHelpers.cs +4 -1
- package/Runtime/Core/Helper/ReflectionHelpers.cs +21 -10
- package/Runtime/Core/Helper/SpriteHelpers.cs +3 -1
- package/Runtime/Core/Helper/UnityMainThreadDispatcher.cs +45 -1
- package/Runtime/Core/Serialization/JsonConverters/GameObjectConverter.cs +13 -5
- package/Runtime/Core/Serialization/JsonConverters/ResolutionConverter.cs +1 -1
- package/Runtime/Core/Serialization/JsonConverters/TypeConverter.cs +1 -1
- package/Runtime/Core/Serialization/ProtobufUnitySurrogates.cs +24 -29
- package/Runtime/Core/Serialization/Serializer.cs +101 -0
- 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/Integrations/VContainer/AssemblyInfo.cs +9 -0
- package/Runtime/Integrations/VContainer/AssemblyInfo.cs.meta +3 -0
- package/Runtime/Integrations/VContainer/ObjectResolverRelationalExtensions.cs +96 -0
- package/Runtime/Integrations/VContainer/RelationalComponentEntryPoint.cs +90 -10
- package/Runtime/Integrations/VContainer/RelationalComponentsBuilderExtensions.cs +13 -1
- package/Runtime/Integrations/VContainer/RelationalObjectPools.cs +114 -0
- package/Runtime/Integrations/VContainer/RelationalObjectPools.cs.meta +11 -0
- package/Runtime/Integrations/VContainer/RelationalSceneAssignmentOptions.cs +16 -4
- package/Runtime/Integrations/VContainer/RelationalSceneLoadListener.cs +241 -0
- package/Runtime/Integrations/VContainer/RelationalSceneLoadListener.cs.meta +11 -0
- package/Runtime/Integrations/Zenject/AssemblyInfo.cs +9 -0
- package/Runtime/Integrations/Zenject/AssemblyInfo.cs.meta +3 -0
- package/Runtime/Integrations/Zenject/DiContainerRelationalExtensions.cs +69 -2
- package/Runtime/Integrations/Zenject/RelationalComponentSceneInitializer.cs +89 -12
- package/Runtime/Integrations/Zenject/RelationalComponentsInstaller.cs +23 -1
- package/Runtime/Integrations/Zenject/RelationalMemoryPools.cs +44 -0
- package/Runtime/Integrations/Zenject/RelationalMemoryPools.cs.meta +11 -0
- package/Runtime/Integrations/Zenject/RelationalSceneAssignmentOptions.cs +16 -10
- package/Runtime/Integrations/Zenject/RelationalSceneLoadListener.cs +243 -0
- package/Runtime/Integrations/Zenject/RelationalSceneLoadListener.cs.meta +11 -0
- package/Runtime/Tags/AttributeMetadataCache.cs +1 -4
- package/Runtime/Utils/Buffers.cs +4 -4
- package/Runtime/Utils/ScriptableObjectSingleton.cs +1 -2
- package/Runtime/Utils/SetTextureImportData.cs +3 -1
- package/Runtime/Utils/TextureScale.cs +10 -2
- package/Runtime/Visuals/UGUI/EnhancedImage.cs +6 -0
- package/Runtime/Visuals/UIToolkit/LayeredImage.cs +4 -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 +238 -56
- package/Samples~/DI - VContainer/Scripts/GameLifetimeScope.cs +22 -4
- package/Samples~/DI - VContainer/Scripts/RelationalConsumer.cs +5 -2
- package/Samples~/DI - VContainer/Scripts/Spawner.cs +113 -4
- package/Samples~/DI - Zenject/README.md +223 -58
- package/Samples~/DI - Zenject/Scripts/RelationalConsumer.cs +3 -0
- package/Samples~/DI - Zenject/Scripts/RelationalConsumerPool.cs +37 -0
- package/Samples~/DI - Zenject/Scripts/RelationalConsumerPool.cs.meta +12 -0
- package/Samples~/DI - Zenject/Scripts/SpawnerZenject.cs +74 -3
- package/Samples~/Random - PRNG/README.md +2 -1
- package/Samples~/Relational Components - Basic/README.md +3 -1
- package/Samples~/Serialization - JSON/README.md +2 -1
- package/Samples~/Spatial Structures - 2D and 3D/README.md +2 -1
- package/Samples~/UGUI - EnhancedImage/README.md +2 -1
- package/Samples~/UI Toolkit - MultiFile Selector (Editor)/README.md +2 -1
- package/Tests/Editor/Attributes/AnimationEventHelpersTests.cs +16 -0
- package/Tests/Editor/Core/Attributes/RelationalComponentAssignerTests.cs +32 -34
- 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 +21 -18
- package/Tests/Editor/Integrations/VContainer/VContainerRelationalHelpersTests.cs +164 -0
- package/Tests/Editor/Integrations/VContainer/VContainerRelationalHelpersTests.cs.meta +11 -0
- package/Tests/Editor/Integrations/VContainer/WallstopStudios.UnityHelpers.Tests.Editor.VContainer.asmdef +2 -1
- package/Tests/Editor/Integrations/Zenject/WallstopStudios.UnityHelpers.Tests.Editor.Zenject.asmdef +3 -2
- package/Tests/Editor/Integrations/Zenject/ZenjectRelationalHelpersTests.cs +127 -0
- package/Tests/Editor/Integrations/Zenject/ZenjectRelationalHelpersTests.cs.meta +11 -0
- package/Tests/Editor/Integrations/Zenject/ZenjectRelationalInitializerTests.cs +25 -23
- package/Tests/Editor/PersistentDirectorySettingsTests.cs +58 -0
- package/Tests/Editor/PersistentDirectorySettingsTests.cs.meta +11 -0
- package/Tests/Editor/PrefabCheckerReportTests.cs +32 -0
- package/Tests/Editor/PrefabCheckerReportTests.cs.meta +11 -0
- package/Tests/Editor/Sprites/AnimationCopierFilterTests.cs +63 -0
- package/Tests/Editor/Sprites/AnimationCopierFilterTests.cs.meta +11 -0
- package/Tests/Editor/Sprites/AnimationCopierWindowTests.cs +1 -1
- package/Tests/Editor/Sprites/AnimationViewerWindowTests.cs +38 -0
- package/Tests/Editor/Sprites/AnimationViewerWindowTests.cs.meta +11 -0
- package/Tests/Editor/Sprites/ScriptableSpriteAtlasEditorTests.cs +1 -1
- package/Tests/Editor/Sprites/SpriteCropperAdditionalTests.cs +12 -12
- package/Tests/Editor/Sprites/SpriteCropperTests.cs +9 -9
- package/Tests/Editor/Sprites/SpritePivotAdjusterTests.cs +3 -3
- package/Tests/Editor/Sprites/TexturePlatformNameHelperTests.cs +18 -0
- package/Tests/Editor/Sprites/TextureResizerWizardTests.cs +5 -5
- package/Tests/Editor/Sprites/TextureSettingsApplierAPITests.cs +3 -3
- package/Tests/Editor/Sprites/TextureSettingsApplierWizardAdditionalTests.cs +4 -4
- package/Tests/Editor/Sprites/TextureSettingsApplierWizardTests.cs +4 -4
- package/Tests/Editor/Tools/ImageBlurToolTests.cs +22 -110
- package/Tests/Editor/Utils/CommonTestBase.cs +60 -1
- package/Tests/Editor/Utils/ScriptableObjectSingletonCreatorTests.cs +6 -6
- package/Tests/Editor/Windows/FitTextureSizeWindowTests.cs +66 -74
- package/Tests/Runtime/Attributes/RelationalComponentInitializerTests.cs +4 -15
- package/Tests/Runtime/DataStructures/SpatialTree3DBoundsConsistencyTests.cs +29 -29
- 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 +257 -221
- package/Tests/Runtime/Integrations/VContainer/RelationalObjectPoolsVContainerTests.cs +91 -0
- package/Tests/Runtime/Integrations/VContainer/RelationalObjectPoolsVContainerTests.cs.meta +11 -0
- package/Tests/Runtime/Integrations/Zenject/RelationalComponentsZenjectTests.cs +251 -233
- package/Tests/Runtime/Performance/RandomPerformanceTests.cs +1 -1
- package/Tests/Runtime/Performance/SpatialTree2DPerformanceTests.cs +6 -1
- package/Tests/Runtime/Performance/SpatialTree3DPerformanceTests.cs +4 -1
- package/Tests/Runtime/Serialization/JsonConverterAdditionalTests.cs +30 -0
- package/Tests/Runtime/Serialization/JsonConverterAdditionalTests.cs.meta +11 -0
- package/Tests/Runtime/Serialization/JsonConverterTests.cs +8 -12
- package/Tests/Runtime/Serialization/JsonRoundtripComprehensiveTests.cs +4 -9
- package/Tests/Runtime/Serialization/JsonSerializationTest.cs +16 -5
- package/Tests/Runtime/Serialization/ProtoRoundtripComprehensiveTests.cs +13 -13
- package/Tests/Runtime/Serialization/SerializerAdditionalTests.cs +12 -0
- package/Tests/Runtime/Serialization/SerializerFileIoTests.cs +105 -0
- package/Tests/Runtime/Serialization/SerializerFileIoTests.cs.meta +11 -0
- package/Tests/Runtime/Serialization/UnityEngineObjectJsonTests.cs +247 -0
- package/Tests/Runtime/Serialization/UnityEngineObjectJsonTests.cs.meta +11 -0
- package/Tests/Runtime/TestUtils/CommonTestBase.cs +99 -0
- package/Tests/Runtime/TestUtils/ReflexTestSupport.cs +111 -0
- package/Tests/Runtime/TestUtils/ReflexTestSupport.cs.meta +12 -0
- package/Tests/Runtime/Utils/CoroutineHandlerTests.cs +1 -1
- package/Tests/Runtime/Utils/LZMAComprehensiveTests.cs +1 -1
- package/Tests/Runtime/Utils/LZMATests.cs +1 -1
- package/Tests/Runtime/Utils/MatchColliderToSpriteTests.cs +5 -5
- package/Tests/Runtime/Visuals/EnhancedImageTests.cs +25 -56
- package/Tests/Runtime/Visuals/VisualsTestHelpers.cs +1 -8
- package/Tests/TestUtils.meta +8 -0
- package/package-lock.json.meta +7 -0
- package/package.json +13 -4
- package/scripts/check-eol.ps1 +4 -5
- package/scripts/lint-tests.ps1 +156 -0
- package/scripts/lint-tests.ps1.meta +7 -0
- package/scripts/normalize-eol.ps1 +6 -9
- package/.github/workflows/csharpier.yml +0 -135
- package/CHANGELOG.md +0 -0
- package/EFFECTS_SYSTEM.md +0 -242
- package/MATH_AND_EXTENSIONS.md +0 -316
- package/SPATIAL_TREE_2D_PERFORMANCE.md +0 -238
- package/SPATIAL_TREE_3D_PERFORMANCE.md +0 -240
- /package/{CHANGELOG.md.meta → Docs/CHANGELOG.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.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.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.meta → Docs/THIRD_PARTY_NOTICES.md.meta} +0 -0
|
@@ -7,14 +7,85 @@ namespace Samples.UnityHelpers.DI.Zenject
|
|
|
7
7
|
public sealed class SpawnerZenject : MonoBehaviour
|
|
8
8
|
{
|
|
9
9
|
[SerializeField]
|
|
10
|
-
private RelationalConsumer
|
|
10
|
+
private RelationalConsumer _componentPrefab;
|
|
11
|
+
|
|
12
|
+
[SerializeField]
|
|
13
|
+
private GameObject _hierarchyPrefab;
|
|
14
|
+
|
|
15
|
+
[SerializeField]
|
|
16
|
+
private Transform _defaultParent;
|
|
11
17
|
|
|
12
18
|
[Inject]
|
|
13
19
|
private DiContainer _container;
|
|
14
20
|
|
|
15
|
-
|
|
21
|
+
[Inject(Optional = true)]
|
|
22
|
+
private RelationalConsumerPool _pool;
|
|
23
|
+
|
|
24
|
+
/// <summary>
|
|
25
|
+
/// Instantiate a component prefab through Zenject so dependencies and relational fields are populated automatically.
|
|
26
|
+
/// </summary>
|
|
27
|
+
public RelationalConsumer SpawnComponent(Transform parent)
|
|
28
|
+
{
|
|
29
|
+
Transform targetParent = parent != null ? parent : _defaultParent;
|
|
30
|
+
return _container.InstantiateComponentWithRelations(_componentPrefab, targetParent);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/// <summary>
|
|
34
|
+
/// Instantiate a hierarchy prefab and hydrate every attributed component beneath it.
|
|
35
|
+
/// </summary>
|
|
36
|
+
public GameObject SpawnHierarchy(Transform parent)
|
|
37
|
+
{
|
|
38
|
+
Transform targetParent = parent != null ? parent : _defaultParent;
|
|
39
|
+
return _container.InstantiateGameObjectWithRelations(
|
|
40
|
+
_hierarchyPrefab,
|
|
41
|
+
targetParent,
|
|
42
|
+
includeInactiveChildren: true
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/// <summary>
|
|
47
|
+
/// Rent an instance from a Zenject memory pool (falls back to SpawnComponent when the pool is not bound).
|
|
48
|
+
/// </summary>
|
|
49
|
+
public RelationalConsumer SpawnFromPool(Transform parent)
|
|
50
|
+
{
|
|
51
|
+
if (_pool == null)
|
|
52
|
+
{
|
|
53
|
+
return SpawnComponent(parent);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
RelationalConsumer instance = _pool.Spawn();
|
|
57
|
+
Transform targetParent = parent != null ? parent : _defaultParent;
|
|
58
|
+
if (targetParent != null)
|
|
59
|
+
{
|
|
60
|
+
instance.transform.SetParent(targetParent, false);
|
|
61
|
+
}
|
|
62
|
+
return instance;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/// <summary>
|
|
66
|
+
/// Return an instance to the pool.
|
|
67
|
+
/// </summary>
|
|
68
|
+
public void DespawnToPool(RelationalConsumer instance)
|
|
16
69
|
{
|
|
17
|
-
|
|
70
|
+
if (_pool == null || instance == null)
|
|
71
|
+
{
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
_pool.Despawn(instance);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/// <summary>
|
|
79
|
+
/// Hydrate an existing hierarchy that was created outside of the container (editor tooling etc.).
|
|
80
|
+
/// </summary>
|
|
81
|
+
public void HydrateExistingHierarchy(GameObject root)
|
|
82
|
+
{
|
|
83
|
+
if (root == null)
|
|
84
|
+
{
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
_container.AssignRelationalHierarchy(root, includeInactiveChildren: true);
|
|
18
89
|
}
|
|
19
90
|
}
|
|
20
91
|
}
|
|
@@ -3,10 +3,11 @@ Random – PRNG Utilities
|
|
|
3
3
|
Shows quick usage of the high-quality PRNGs (e.g., PCG) for integers, floats, Gaussian values, and sampling from collections.
|
|
4
4
|
|
|
5
5
|
How to use
|
|
6
|
+
|
|
6
7
|
- Add `RandomPrngDemo` to any GameObject and press Play.
|
|
7
8
|
- Optionally change the `seed` in the inspector for deterministic sequences.
|
|
8
9
|
|
|
9
10
|
What it shows
|
|
11
|
+
|
|
10
12
|
- `PcgRandom` construction with a seed and sampling `Next`, `NextFloat`, `NextGaussian`.
|
|
11
13
|
- `NextOf` to pick elements from lists.
|
|
12
|
-
|
|
@@ -3,17 +3,19 @@ Relational Components – Basic
|
|
|
3
3
|
This sample demonstrates the built-in Relational Component Attributes without any DI container. Attach the script to a GameObject hierarchy and the fields are auto-assigned at runtime.
|
|
4
4
|
|
|
5
5
|
How to use
|
|
6
|
+
|
|
6
7
|
- Open any scene and create a simple hierarchy with a parent, a child, and a sibling next to the consumer object.
|
|
7
8
|
- Add `RelationalBasicConsumer` to the child object.
|
|
8
9
|
- Enter Play Mode and check the Console for the assigned references.
|
|
9
10
|
|
|
10
11
|
What it shows
|
|
12
|
+
|
|
11
13
|
- `[ParentComponent]` finds components on ancestors (configurable depth).
|
|
12
14
|
- `[SiblingComponent]` finds components on the same GameObject.
|
|
13
15
|
- `[ChildComponent]` finds components on children (recursively).
|
|
14
16
|
- `this.AssignRelationalComponents()` hydrates all relational fields in `Awake()`/`OnEnable()`.
|
|
15
17
|
|
|
16
18
|
Notes
|
|
19
|
+
|
|
17
20
|
- You can adjust filters on attributes: `Optional`, `IncludeInactive`, `TagFilter`, `NameFilter`, and `MaxCount` for collections.
|
|
18
21
|
- For DI integrations, see the separate VContainer/Zenject samples.
|
|
19
|
-
|
|
@@ -3,11 +3,12 @@ Serialization – JSON Converters
|
|
|
3
3
|
Demonstrates serialization of Unity types using System.Text.Json with Unity Helpers’ built-in converters and helper APIs.
|
|
4
4
|
|
|
5
5
|
How to use
|
|
6
|
+
|
|
6
7
|
- Add `JsonSerializationDemo` to any GameObject and press Play.
|
|
7
8
|
- Check the Console for serialized JSON, byte sizes, and a round-trip decode.
|
|
8
9
|
|
|
9
10
|
What it shows
|
|
11
|
+
|
|
10
12
|
- `Serializer.JsonStringify` and `Serializer.JsonDeserialize<T>` for text workflows.
|
|
11
13
|
- `Serializer.JsonSerialize` and `Serializer.JsonDeserialize<T>(byte[])` for UTF-8 bytes.
|
|
12
14
|
- Using `Serializer.CreateFastJsonOptions()` for hot paths.
|
|
13
|
-
|
|
@@ -3,11 +3,12 @@ Spatial Structures – 2D and 3D
|
|
|
3
3
|
Demonstrates building and querying spatial structures for static point sets and grid-based indexing.
|
|
4
4
|
|
|
5
5
|
How to use
|
|
6
|
+
|
|
6
7
|
- Add `SpatialStructuresDemo` to any GameObject and press Play.
|
|
7
8
|
- Adjust `pointCount`, `areaSize`, and `queryRadius` in the inspector.
|
|
8
9
|
|
|
9
10
|
What it shows
|
|
11
|
+
|
|
10
12
|
- `QuadTree2D<T>` created from points with a transformer and radius query.
|
|
11
13
|
- `KdTree2D<T>` approximate nearest neighbors.
|
|
12
14
|
- `SpatialHash2D<T>` bucketed insertion and radius query.
|
|
13
|
-
|
|
@@ -3,10 +3,11 @@ UGUI – EnhancedImage
|
|
|
3
3
|
Shows programmatic setup and basic usage of `EnhancedImage` with HDR tinting.
|
|
4
4
|
|
|
5
5
|
How to use
|
|
6
|
+
|
|
6
7
|
- Add `EnhancedImageDemo` to an empty scene and press Play.
|
|
7
8
|
- Optionally assign a `materialTemplate` in the inspector to use a shader that exposes `_Color` and optional `_ShapeMask`.
|
|
8
9
|
|
|
9
10
|
What it shows
|
|
11
|
+
|
|
10
12
|
- Creating a `Canvas` and an `EnhancedImage` at runtime.
|
|
11
13
|
- Setting an HDR tint via `HdrColor` (values > 1).
|
|
12
|
-
|
|
@@ -3,10 +3,11 @@ UI Toolkit – MultiFile Selector (Editor)
|
|
|
3
3
|
A minimal EditorWindow showcasing `MultiFileSelectorElement` for fast in-Editor multi-file selection with breadcrumbs, filtering and virtualization.
|
|
4
4
|
|
|
5
5
|
How to use
|
|
6
|
+
|
|
6
7
|
- Import the sample, then open: `Window > Unity Helpers > MultiFile Selector Sample`.
|
|
7
8
|
- Pick extensions and select multiple files; results are logged to the Console.
|
|
8
9
|
|
|
9
10
|
What it shows
|
|
11
|
+
|
|
10
12
|
- Creating and adding `MultiFileSelectorElement` to an EditorWindow.
|
|
11
13
|
- Hooks for `OnFilesSelected` and `OnCancelled`.
|
|
12
|
-
|
|
@@ -93,6 +93,22 @@ namespace WallstopStudios.UnityHelpers.Tests.Editor.Attributes
|
|
|
93
93
|
|
|
94
94
|
CollectionAssert.AreEquivalent(expected, methods.Select(method => method.Name));
|
|
95
95
|
}
|
|
96
|
+
|
|
97
|
+
[Test]
|
|
98
|
+
public void GetPossibleAnimatorEventsAreSortedByName()
|
|
99
|
+
{
|
|
100
|
+
List<MethodInfo> methods = AnimationEventHelpers.GetPossibleAnimatorEventsForType(
|
|
101
|
+
typeof(AnimationEventSignatureHost)
|
|
102
|
+
);
|
|
103
|
+
// Ensure ascending ordinal sort by method name
|
|
104
|
+
for (int i = 1; i < methods.Count; i++)
|
|
105
|
+
{
|
|
106
|
+
Assert.LessOrEqual(
|
|
107
|
+
string.Compare(methods[i - 1].Name, methods[i].Name, StringComparison.Ordinal),
|
|
108
|
+
0
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
96
112
|
}
|
|
97
113
|
|
|
98
114
|
internal enum AnimationEventSignal
|
|
@@ -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>();
|
|
@@ -98,13 +96,13 @@ namespace WallstopStudios.UnityHelpers.Tests.Core.Attributes
|
|
|
98
96
|
GameObject go2 = NewGameObject("NonRelational");
|
|
99
97
|
NonRelational non = go2.AddComponent<NonRelational>();
|
|
100
98
|
|
|
101
|
-
Assert.
|
|
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
|
-
Assert.
|
|
107
|
-
consumer.SR,
|
|
104
|
+
Assert.IsTrue(
|
|
105
|
+
consumer.SR != null,
|
|
108
106
|
"Relational field should be assigned by Assign(IEnumerable<Component>)"
|
|
109
107
|
);
|
|
110
108
|
|
|
@@ -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>(),
|
|
@@ -55,10 +54,11 @@ namespace WallstopStudios.UnityHelpers.Tests.Integrations.VContainer
|
|
|
55
54
|
new[] { relationalMetadata }
|
|
56
55
|
);
|
|
57
56
|
cache.ForceRebuildForTests();
|
|
57
|
+
yield return null;
|
|
58
58
|
#endif
|
|
59
59
|
|
|
60
|
-
RelationalComponentAssigner assigner = new
|
|
61
|
-
RelationalComponentEntryPoint entry = new
|
|
60
|
+
RelationalComponentAssigner assigner = new(cache);
|
|
61
|
+
RelationalComponentEntryPoint entry = new(
|
|
62
62
|
assigner,
|
|
63
63
|
cache,
|
|
64
64
|
RelationalSceneAssignmentOptions.Default
|
|
@@ -69,8 +69,11 @@ namespace WallstopStudios.UnityHelpers.Tests.Integrations.VContainer
|
|
|
69
69
|
// Allow assignment to complete
|
|
70
70
|
yield return null;
|
|
71
71
|
|
|
72
|
-
Assert.
|
|
73
|
-
Assert.
|
|
72
|
+
Assert.IsTrue(consumer != null);
|
|
73
|
+
Assert.IsTrue(
|
|
74
|
+
consumer.SR != null,
|
|
75
|
+
"Relational field should be assigned by entry point"
|
|
76
|
+
);
|
|
74
77
|
}
|
|
75
78
|
}
|
|
76
79
|
}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
#if VCONTAINER_PRESENT
|
|
2
|
+
namespace WallstopStudios.UnityHelpers.Tests.Integrations.VContainer
|
|
3
|
+
{
|
|
4
|
+
using global::VContainer;
|
|
5
|
+
using NUnit.Framework;
|
|
6
|
+
using UnityEngine;
|
|
7
|
+
using WallstopStudios.UnityHelpers.Core.Attributes;
|
|
8
|
+
using WallstopStudios.UnityHelpers.Integrations.VContainer;
|
|
9
|
+
using WallstopStudios.UnityHelpers.Tags;
|
|
10
|
+
using WallstopStudios.UnityHelpers.Tests.Editor.Utils;
|
|
11
|
+
|
|
12
|
+
public sealed class VContainerRelationalHelpersTests : CommonTestBase
|
|
13
|
+
{
|
|
14
|
+
private sealed class TestComponent : MonoBehaviour
|
|
15
|
+
{
|
|
16
|
+
[ParentComponent(OnlyAncestors = true)]
|
|
17
|
+
public Rigidbody parentBody;
|
|
18
|
+
|
|
19
|
+
[ChildComponent(OnlyDescendants = true)]
|
|
20
|
+
public CapsuleCollider childCollider;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
[Test]
|
|
24
|
+
public void InjectWithRelationsAssignsFields()
|
|
25
|
+
{
|
|
26
|
+
ContainerBuilder builder = new();
|
|
27
|
+
IObjectResolver resolver = builder.Build();
|
|
28
|
+
|
|
29
|
+
// Build hierarchy: Parent(Rigidbody) -> Middle(TestComponent) -> Child(CapsuleCollider)
|
|
30
|
+
GameObject parent = NewGameObject("Parent");
|
|
31
|
+
parent.AddComponent<Rigidbody>();
|
|
32
|
+
GameObject middle = NewGameObject("Middle");
|
|
33
|
+
middle.transform.SetParent(parent.transform);
|
|
34
|
+
TestComponent comp = middle.AddComponent<TestComponent>();
|
|
35
|
+
GameObject child = NewGameObject("Child");
|
|
36
|
+
child.transform.SetParent(middle.transform);
|
|
37
|
+
child.AddComponent<CapsuleCollider>();
|
|
38
|
+
|
|
39
|
+
TestComponent result = resolver.InjectWithRelations(comp);
|
|
40
|
+
|
|
41
|
+
Assert.That(result, Is.SameAs(comp));
|
|
42
|
+
Assert.IsTrue(comp.parentBody != null);
|
|
43
|
+
Assert.IsTrue(comp.childCollider != null);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
[Test]
|
|
47
|
+
public void InstantiateComponentWithRelationsAssignsFields()
|
|
48
|
+
{
|
|
49
|
+
ContainerBuilder builder = new();
|
|
50
|
+
IObjectResolver resolver = builder.Build();
|
|
51
|
+
|
|
52
|
+
// Build prefab hierarchy: Root(Rigidbody) -> Middle(TestComponent) -> Child(CapsuleCollider)
|
|
53
|
+
GameObject prefabRoot = NewGameObject("PrefabRoot");
|
|
54
|
+
prefabRoot.AddComponent<Rigidbody>();
|
|
55
|
+
GameObject prefabMiddle = NewGameObject("PrefabMiddle");
|
|
56
|
+
prefabMiddle.transform.SetParent(prefabRoot.transform);
|
|
57
|
+
TestComponent prefabComp = prefabMiddle.AddComponent<TestComponent>();
|
|
58
|
+
GameObject prefabChild = NewGameObject("PrefabChild");
|
|
59
|
+
prefabChild.transform.SetParent(prefabMiddle.transform);
|
|
60
|
+
prefabChild.AddComponent<CapsuleCollider>();
|
|
61
|
+
|
|
62
|
+
// Instantiate the full hierarchy and hydrate via GO helper
|
|
63
|
+
GameObject instanceRoot = resolver.InstantiateGameObjectWithRelations(prefabRoot);
|
|
64
|
+
TestComponent instance = instanceRoot.GetComponentInChildren<TestComponent>(true);
|
|
65
|
+
|
|
66
|
+
Assert.IsTrue(instance != null);
|
|
67
|
+
Assert.IsTrue(instance.parentBody != null);
|
|
68
|
+
Assert.IsTrue(instance.childCollider != null);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
[Test]
|
|
72
|
+
public void InjectGameObjectWithRelationsAssignsHierarchy()
|
|
73
|
+
{
|
|
74
|
+
ContainerBuilder builder = new();
|
|
75
|
+
IObjectResolver resolver = builder.Build();
|
|
76
|
+
|
|
77
|
+
GameObject root = NewGameObject("Root");
|
|
78
|
+
root.AddComponent<Rigidbody>();
|
|
79
|
+
GameObject middle = NewGameObject("Middle");
|
|
80
|
+
middle.transform.SetParent(root.transform);
|
|
81
|
+
TestComponent comp = middle.AddComponent<TestComponent>();
|
|
82
|
+
GameObject child = NewGameObject("Child");
|
|
83
|
+
child.transform.SetParent(middle.transform);
|
|
84
|
+
child.AddComponent<CapsuleCollider>();
|
|
85
|
+
|
|
86
|
+
resolver.InjectGameObjectWithRelations(root);
|
|
87
|
+
|
|
88
|
+
Assert.IsTrue(comp.parentBody != null);
|
|
89
|
+
Assert.IsTrue(comp.childCollider != null);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
[Test]
|
|
93
|
+
public void InstantiateGameObjectWithRelationsAssignsHierarchy()
|
|
94
|
+
{
|
|
95
|
+
ContainerBuilder builder = new();
|
|
96
|
+
IObjectResolver resolver = builder.Build();
|
|
97
|
+
|
|
98
|
+
GameObject prefab = NewGameObject("PrefabRoot");
|
|
99
|
+
prefab.AddComponent<Rigidbody>();
|
|
100
|
+
GameObject mid = NewGameObject("PrefabMiddle");
|
|
101
|
+
mid.transform.SetParent(prefab.transform);
|
|
102
|
+
TestComponent prefabComp = mid.AddComponent<TestComponent>();
|
|
103
|
+
GameObject child = NewGameObject("PrefabChild");
|
|
104
|
+
child.transform.SetParent(mid.transform);
|
|
105
|
+
child.AddComponent<CapsuleCollider>();
|
|
106
|
+
|
|
107
|
+
GameObject instance = resolver.InstantiateGameObjectWithRelations(prefab);
|
|
108
|
+
TestComponent comp = instance.GetComponentInChildren<TestComponent>(true);
|
|
109
|
+
|
|
110
|
+
Assert.IsTrue(comp != null);
|
|
111
|
+
Assert.IsTrue(comp.parentBody != null);
|
|
112
|
+
Assert.IsTrue(comp.childCollider != null);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
[Test]
|
|
116
|
+
public void AssignerRecognizesBaseTypeMetadataForDerivedComponents()
|
|
117
|
+
{
|
|
118
|
+
AttributeMetadataCache cache = CreateScriptableObject<AttributeMetadataCache>();
|
|
119
|
+
|
|
120
|
+
AttributeMetadataCache.RelationalFieldMetadata[] fields =
|
|
121
|
+
{
|
|
122
|
+
new(
|
|
123
|
+
nameof(BaseWithSibling._spriteRenderer),
|
|
124
|
+
AttributeMetadataCache.RelationalAttributeKind.Sibling,
|
|
125
|
+
AttributeMetadataCache.FieldKind.Single,
|
|
126
|
+
typeof(SpriteRenderer).AssemblyQualifiedName,
|
|
127
|
+
false
|
|
128
|
+
),
|
|
129
|
+
};
|
|
130
|
+
AttributeMetadataCache.RelationalTypeMetadata[] relational =
|
|
131
|
+
{
|
|
132
|
+
new(typeof(BaseWithSibling).AssemblyQualifiedName, fields),
|
|
133
|
+
};
|
|
134
|
+
cache._relationalTypeMetadata = relational;
|
|
135
|
+
cache.ForceRebuildForTests();
|
|
136
|
+
|
|
137
|
+
ContainerBuilder builder = new();
|
|
138
|
+
builder.RegisterInstance(cache).AsSelf();
|
|
139
|
+
builder
|
|
140
|
+
.RegisterInstance(new RelationalComponentAssigner(cache))
|
|
141
|
+
.As<IRelationalComponentAssigner>();
|
|
142
|
+
IObjectResolver resolver = builder.Build();
|
|
143
|
+
|
|
144
|
+
GameObject go = NewGameObject("Root");
|
|
145
|
+
go.AddComponent<SpriteRenderer>();
|
|
146
|
+
DerivedWithSibling comp = go.AddComponent<DerivedWithSibling>();
|
|
147
|
+
|
|
148
|
+
resolver.AssignRelationalComponents(comp);
|
|
149
|
+
|
|
150
|
+
Assert.IsTrue(comp.SR != null);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
private class BaseWithSibling : MonoBehaviour
|
|
154
|
+
{
|
|
155
|
+
[SiblingComponent]
|
|
156
|
+
protected internal SpriteRenderer _spriteRenderer;
|
|
157
|
+
|
|
158
|
+
public SpriteRenderer SR => _spriteRenderer;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
private sealed class DerivedWithSibling : BaseWithSibling { }
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
#endif
|
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
"UnityEngine.TestRunner",
|
|
7
7
|
"WallstopStudios.UnityHelpers",
|
|
8
8
|
"WallstopStudios.UnityHelpers.Integration.VContainer",
|
|
9
|
-
"WallstopStudios.UnityHelpers.Tests.Editor"
|
|
9
|
+
"WallstopStudios.UnityHelpers.Tests.Editor",
|
|
10
|
+
"VContainer"
|
|
10
11
|
],
|
|
11
12
|
"includePlatforms": ["Editor"],
|
|
12
13
|
"excludePlatforms": [],
|