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
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
#if REFLEX_PRESENT
|
|
2
|
+
namespace WallstopStudios.UnityHelpers.Integrations.Reflex
|
|
3
|
+
{
|
|
4
|
+
using System;
|
|
5
|
+
using System.Collections.Generic;
|
|
6
|
+
using global::Reflex.Core;
|
|
7
|
+
using UnityEngine;
|
|
8
|
+
using UnityEngine.SceneManagement;
|
|
9
|
+
using WallstopStudios.UnityHelpers.Core.Attributes;
|
|
10
|
+
using WallstopStudios.UnityHelpers.Tags;
|
|
11
|
+
using WallstopStudios.UnityHelpers.Utils;
|
|
12
|
+
|
|
13
|
+
internal static class RelationalReflexSceneBootstrapper
|
|
14
|
+
{
|
|
15
|
+
public static void ConfigureScene(
|
|
16
|
+
Container container,
|
|
17
|
+
Scene scene,
|
|
18
|
+
RelationalSceneAssignmentOptions options,
|
|
19
|
+
bool assignSceneOnInitialize,
|
|
20
|
+
bool listenForAdditiveScenes
|
|
21
|
+
)
|
|
22
|
+
{
|
|
23
|
+
if (container == null)
|
|
24
|
+
{
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
IRelationalComponentAssigner assigner = ResolveAssigner(container);
|
|
29
|
+
if (assigner == null)
|
|
30
|
+
{
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
AttributeMetadataCache metadataCache = ResolveMetadata(container);
|
|
35
|
+
|
|
36
|
+
if (assignSceneOnInitialize)
|
|
37
|
+
{
|
|
38
|
+
AssignScene(scene, assigner, metadataCache, options);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (listenForAdditiveScenes)
|
|
42
|
+
{
|
|
43
|
+
RelationalSceneLoadListener listener = new(assigner, metadataCache, options, scene);
|
|
44
|
+
listener.Activate();
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
internal static void AssignScene(
|
|
49
|
+
Scene scene,
|
|
50
|
+
IRelationalComponentAssigner assigner,
|
|
51
|
+
AttributeMetadataCache metadataCache,
|
|
52
|
+
RelationalSceneAssignmentOptions options
|
|
53
|
+
)
|
|
54
|
+
{
|
|
55
|
+
if (!scene.IsValid() || assigner == null)
|
|
56
|
+
{
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
AttributeMetadataCache cache = metadataCache ?? AttributeMetadataCache.Instance;
|
|
61
|
+
if (cache == null)
|
|
62
|
+
{
|
|
63
|
+
AssignBySceneRoots(scene, assigner, options.IncludeInactive);
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
using PooledResource<List<Type>> typeBuffer = Buffers<Type>.List.Get(
|
|
68
|
+
out List<Type> relationalTypes
|
|
69
|
+
);
|
|
70
|
+
cache.CollectRelationalComponentTypes(relationalTypes);
|
|
71
|
+
|
|
72
|
+
if (relationalTypes.Count == 0)
|
|
73
|
+
{
|
|
74
|
+
AssignBySceneRoots(scene, assigner, options.IncludeInactive);
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (options.UseSinglePassScan)
|
|
79
|
+
{
|
|
80
|
+
AssignBySinglePass(scene, assigner, relationalTypes, options.IncludeInactive);
|
|
81
|
+
}
|
|
82
|
+
else
|
|
83
|
+
{
|
|
84
|
+
AssignByTypePass(scene, assigner, relationalTypes, options.IncludeInactive);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
#if UNITY_EDITOR
|
|
88
|
+
if (!Application.isPlaying)
|
|
89
|
+
{
|
|
90
|
+
AssignBySceneRoots(scene, assigner, options.IncludeInactive);
|
|
91
|
+
UnityEditor.EditorApplication.delayCall += () =>
|
|
92
|
+
{
|
|
93
|
+
if (scene.IsValid())
|
|
94
|
+
{
|
|
95
|
+
AssignBySceneRoots(scene, assigner, options.IncludeInactive);
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
#endif
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
private static void AssignByTypePass(
|
|
103
|
+
Scene target,
|
|
104
|
+
IRelationalComponentAssigner assigner,
|
|
105
|
+
List<Type> relationalTypes,
|
|
106
|
+
bool includeInactive
|
|
107
|
+
)
|
|
108
|
+
{
|
|
109
|
+
using PooledResource<List<GameObject>> rootBuffer = Buffers<GameObject>.List.Get(
|
|
110
|
+
out List<GameObject> roots
|
|
111
|
+
);
|
|
112
|
+
target.GetRootGameObjects(roots);
|
|
113
|
+
if (roots.Count == 0)
|
|
114
|
+
{
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
using PooledResource<HashSet<Type>> typeSetPool = Buffers<Type>.HashSet.Get(
|
|
119
|
+
out HashSet<Type> relationalSet
|
|
120
|
+
);
|
|
121
|
+
for (int i = 0; i < relationalTypes.Count; i++)
|
|
122
|
+
{
|
|
123
|
+
Type type = relationalTypes[i];
|
|
124
|
+
if (type != null)
|
|
125
|
+
{
|
|
126
|
+
relationalSet.Add(type);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
using PooledResource<List<Component>> componentBuffer = Buffers<Component>.List.Get(
|
|
131
|
+
out List<Component> components
|
|
132
|
+
);
|
|
133
|
+
|
|
134
|
+
for (int i = 0; i < roots.Count; i++)
|
|
135
|
+
{
|
|
136
|
+
GameObject root = roots[i];
|
|
137
|
+
if (root == null)
|
|
138
|
+
{
|
|
139
|
+
continue;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
root.GetComponentsInChildren(includeInactive, components);
|
|
143
|
+
for (int j = 0; j < components.Count; j++)
|
|
144
|
+
{
|
|
145
|
+
Component component = components[j];
|
|
146
|
+
if (component == null || component.gameObject.scene != target)
|
|
147
|
+
{
|
|
148
|
+
continue;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
Type current = component.GetType();
|
|
152
|
+
while (current != null && typeof(Component).IsAssignableFrom(current))
|
|
153
|
+
{
|
|
154
|
+
if (relationalSet.Contains(current))
|
|
155
|
+
{
|
|
156
|
+
assigner.Assign(component);
|
|
157
|
+
break;
|
|
158
|
+
}
|
|
159
|
+
current = current.BaseType;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
components.Clear();
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
private static void AssignBySinglePass(
|
|
168
|
+
Scene target,
|
|
169
|
+
IRelationalComponentAssigner assigner,
|
|
170
|
+
List<Type> relationalTypes,
|
|
171
|
+
bool includeInactive
|
|
172
|
+
)
|
|
173
|
+
{
|
|
174
|
+
using PooledResource<HashSet<Type>> pooledSet = Buffers<Type>.HashSet.Get(
|
|
175
|
+
out HashSet<Type> relationalSet
|
|
176
|
+
);
|
|
177
|
+
for (int i = 0; i < relationalTypes.Count; i++)
|
|
178
|
+
{
|
|
179
|
+
Type type = relationalTypes[i];
|
|
180
|
+
if (type != null)
|
|
181
|
+
{
|
|
182
|
+
relationalSet.Add(type);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
Component[] allComponents = includeInactive
|
|
187
|
+
? UnityEngine.Object.FindObjectsOfType<Component>(true)
|
|
188
|
+
: UnityEngine.Object.FindObjectsOfType<Component>(false);
|
|
189
|
+
|
|
190
|
+
for (int i = 0; i < allComponents.Length; i++)
|
|
191
|
+
{
|
|
192
|
+
Component component = allComponents[i];
|
|
193
|
+
if (component == null || component.gameObject.scene != target)
|
|
194
|
+
{
|
|
195
|
+
continue;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
Type current = component.GetType();
|
|
199
|
+
while (current != null && typeof(Component).IsAssignableFrom(current))
|
|
200
|
+
{
|
|
201
|
+
if (relationalSet.Contains(current))
|
|
202
|
+
{
|
|
203
|
+
assigner.Assign(component);
|
|
204
|
+
break;
|
|
205
|
+
}
|
|
206
|
+
current = current.BaseType;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
private static void AssignBySceneRoots(
|
|
212
|
+
Scene target,
|
|
213
|
+
IRelationalComponentAssigner assigner,
|
|
214
|
+
bool includeInactive
|
|
215
|
+
)
|
|
216
|
+
{
|
|
217
|
+
if (!target.IsValid())
|
|
218
|
+
{
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
using PooledResource<List<GameObject>> rootBuffer = Buffers<GameObject>.List.Get(
|
|
223
|
+
out List<GameObject> roots
|
|
224
|
+
);
|
|
225
|
+
target.GetRootGameObjects(roots);
|
|
226
|
+
for (int i = 0; i < roots.Count; i++)
|
|
227
|
+
{
|
|
228
|
+
GameObject root = roots[i];
|
|
229
|
+
if (root == null)
|
|
230
|
+
{
|
|
231
|
+
continue;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
assigner.AssignHierarchy(root, includeInactive);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
private static IRelationalComponentAssigner ResolveAssigner(Container container)
|
|
239
|
+
{
|
|
240
|
+
if (container.HasBinding<IRelationalComponentAssigner>())
|
|
241
|
+
{
|
|
242
|
+
return container.Resolve<IRelationalComponentAssigner>();
|
|
243
|
+
}
|
|
244
|
+
return null;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
private static AttributeMetadataCache ResolveMetadata(Container container)
|
|
248
|
+
{
|
|
249
|
+
if (container.HasBinding<AttributeMetadataCache>())
|
|
250
|
+
{
|
|
251
|
+
return container.Resolve<AttributeMetadataCache>();
|
|
252
|
+
}
|
|
253
|
+
return AttributeMetadataCache.Instance;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
private sealed class RelationalSceneLoadListener
|
|
257
|
+
{
|
|
258
|
+
private readonly IRelationalComponentAssigner _assigner;
|
|
259
|
+
private readonly AttributeMetadataCache _metadataCache;
|
|
260
|
+
private readonly RelationalSceneAssignmentOptions _options;
|
|
261
|
+
private readonly Scene _originScene;
|
|
262
|
+
private bool _isActive;
|
|
263
|
+
|
|
264
|
+
public RelationalSceneLoadListener(
|
|
265
|
+
IRelationalComponentAssigner assigner,
|
|
266
|
+
AttributeMetadataCache metadataCache,
|
|
267
|
+
RelationalSceneAssignmentOptions options,
|
|
268
|
+
Scene originScene
|
|
269
|
+
)
|
|
270
|
+
{
|
|
271
|
+
_assigner = assigner;
|
|
272
|
+
_metadataCache = metadataCache;
|
|
273
|
+
_options = options;
|
|
274
|
+
_originScene = originScene;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
public void Activate()
|
|
278
|
+
{
|
|
279
|
+
if (_isActive)
|
|
280
|
+
{
|
|
281
|
+
return;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
SceneManager.sceneLoaded += OnSceneLoaded;
|
|
285
|
+
SceneManager.sceneUnloaded += OnSceneUnloaded;
|
|
286
|
+
_isActive = true;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
|
|
290
|
+
{
|
|
291
|
+
if (mode != LoadSceneMode.Additive || !_isActive)
|
|
292
|
+
{
|
|
293
|
+
return;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
AssignScene(scene, _assigner, _metadataCache, _options);
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
private void OnSceneUnloaded(Scene scene)
|
|
300
|
+
{
|
|
301
|
+
if (!_isActive)
|
|
302
|
+
{
|
|
303
|
+
return;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
if (scene == _originScene)
|
|
307
|
+
{
|
|
308
|
+
SceneManager.sceneLoaded -= OnSceneLoaded;
|
|
309
|
+
SceneManager.sceneUnloaded -= OnSceneUnloaded;
|
|
310
|
+
_isActive = false;
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
#endif
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
#if REFLEX_PRESENT
|
|
2
|
+
namespace WallstopStudios.UnityHelpers.Integrations.Reflex
|
|
3
|
+
{
|
|
4
|
+
using System;
|
|
5
|
+
using WallstopStudios.UnityHelpers.Core.Helper;
|
|
6
|
+
|
|
7
|
+
/// <summary>
|
|
8
|
+
/// Controls how the Reflex integration performs relational component assignment across scenes.
|
|
9
|
+
/// </summary>
|
|
10
|
+
public readonly struct RelationalSceneAssignmentOptions
|
|
11
|
+
: IEquatable<RelationalSceneAssignmentOptions>
|
|
12
|
+
{
|
|
13
|
+
/// <summary>
|
|
14
|
+
/// Initializes a new instance of the <see cref="RelationalSceneAssignmentOptions"/> struct.
|
|
15
|
+
/// </summary>
|
|
16
|
+
/// <param name="includeInactive">
|
|
17
|
+
/// When true, relational assignment scans include inactive GameObjects. Defaults to true.
|
|
18
|
+
/// </param>
|
|
19
|
+
/// <param name="useSinglePassScan">
|
|
20
|
+
/// When true, performs a single-pass scan for relational types to maximize performance.
|
|
21
|
+
/// Defaults to true.
|
|
22
|
+
/// </param>
|
|
23
|
+
public RelationalSceneAssignmentOptions(bool includeInactive, bool useSinglePassScan = true)
|
|
24
|
+
{
|
|
25
|
+
IncludeInactive = includeInactive;
|
|
26
|
+
UseSinglePassScan = useSinglePassScan;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/// <summary>
|
|
30
|
+
/// Gets default options (include inactive objects, single-pass scan).
|
|
31
|
+
/// </summary>
|
|
32
|
+
public static RelationalSceneAssignmentOptions Default => new(true, true);
|
|
33
|
+
|
|
34
|
+
/// <summary>
|
|
35
|
+
/// Gets whether inactive GameObjects are included during scans.
|
|
36
|
+
/// </summary>
|
|
37
|
+
public bool IncludeInactive { get; }
|
|
38
|
+
|
|
39
|
+
/// <summary>
|
|
40
|
+
/// Gets whether to use a single-pass scan strategy.
|
|
41
|
+
/// </summary>
|
|
42
|
+
public bool UseSinglePassScan { get; }
|
|
43
|
+
|
|
44
|
+
/// <inheritdoc />
|
|
45
|
+
public bool Equals(RelationalSceneAssignmentOptions other)
|
|
46
|
+
{
|
|
47
|
+
return IncludeInactive == other.IncludeInactive
|
|
48
|
+
&& UseSinglePassScan == other.UseSinglePassScan;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/// <inheritdoc />
|
|
52
|
+
public override bool Equals(object obj)
|
|
53
|
+
{
|
|
54
|
+
return obj is RelationalSceneAssignmentOptions other && Equals(other);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/// <inheritdoc />
|
|
58
|
+
public override int GetHashCode()
|
|
59
|
+
{
|
|
60
|
+
return Objects.HashCode(IncludeInactive, UseSinglePassScan);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/// <summary>
|
|
64
|
+
/// Equality operator.
|
|
65
|
+
/// </summary>
|
|
66
|
+
public static bool operator ==(
|
|
67
|
+
RelationalSceneAssignmentOptions left,
|
|
68
|
+
RelationalSceneAssignmentOptions right
|
|
69
|
+
)
|
|
70
|
+
{
|
|
71
|
+
return left.Equals(right);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/// <summary>
|
|
75
|
+
/// Inequality operator.
|
|
76
|
+
/// </summary>
|
|
77
|
+
public static bool operator !=(
|
|
78
|
+
RelationalSceneAssignmentOptions left,
|
|
79
|
+
RelationalSceneAssignmentOptions right
|
|
80
|
+
)
|
|
81
|
+
{
|
|
82
|
+
return !left.Equals(right);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
#endif
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "WallstopStudios.UnityHelpers.Integration.Reflex",
|
|
3
|
+
"rootNamespace": "WallstopStudios.UnityHelpers.Integrations.Reflex",
|
|
4
|
+
"references": ["WallstopStudios.UnityHelpers", "Reflex"],
|
|
5
|
+
"includePlatforms": [],
|
|
6
|
+
"excludePlatforms": [],
|
|
7
|
+
"allowUnsafeCode": false,
|
|
8
|
+
"overrideReferences": false,
|
|
9
|
+
"precompiledReferences": [],
|
|
10
|
+
"autoReferenced": true,
|
|
11
|
+
"defineConstraints": ["REFLEX_PRESENT"],
|
|
12
|
+
"versionDefines": [
|
|
13
|
+
{
|
|
14
|
+
"name": "com.gustavopsantos.reflex",
|
|
15
|
+
"expression": "0.0.1",
|
|
16
|
+
"define": "REFLEX_PRESENT"
|
|
17
|
+
}
|
|
18
|
+
],
|
|
19
|
+
"noEngineReferences": false
|
|
20
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
using System.Runtime.CompilerServices;
|
|
2
|
+
|
|
3
|
+
[assembly: InternalsVisibleTo("WallstopStudios.UnityHelpers.Tests.Editor")]
|
|
4
|
+
[assembly: InternalsVisibleTo("WallstopStudios.UnityHelpers.Tests.Runtime")]
|
|
5
|
+
[assembly: InternalsVisibleTo("WallstopStudios.UnityHelpers.Editor")]
|
|
6
|
+
[assembly: InternalsVisibleTo("WallstopStudios.UnityHelpers.Tests.Runtime.Zenject")]
|
|
7
|
+
[assembly: InternalsVisibleTo("WallstopStudios.UnityHelpers.Tests.Runtime.VContainer")]
|
|
8
|
+
[assembly: InternalsVisibleTo("WallstopStudios.UnityHelpers.Tests.Editor.VContainer")]
|
|
9
|
+
[assembly: InternalsVisibleTo("WallstopStudios.UnityHelpers.Tests.Editor.Zenject")]
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
#if VCONTAINER_PRESENT
|
|
2
2
|
namespace WallstopStudios.UnityHelpers.Integrations.VContainer
|
|
3
3
|
{
|
|
4
|
+
using System;
|
|
4
5
|
using System.Collections.Generic;
|
|
5
6
|
using global::VContainer;
|
|
7
|
+
using global::VContainer.Unity;
|
|
6
8
|
using UnityEngine;
|
|
7
9
|
using WallstopStudios.UnityHelpers.Core.Attributes;
|
|
8
10
|
using WallstopStudios.UnityHelpers.Utils;
|
|
@@ -56,6 +58,27 @@ namespace WallstopStudios.UnityHelpers.Integrations.VContainer
|
|
|
56
58
|
/// </example>
|
|
57
59
|
public static class ObjectResolverRelationalExtensions
|
|
58
60
|
{
|
|
61
|
+
/// <summary>
|
|
62
|
+
/// Injects <paramref name="component"/> with VContainer and assigns its relational fields.
|
|
63
|
+
/// </summary>
|
|
64
|
+
/// <typeparam name="T">The component type.</typeparam>
|
|
65
|
+
/// <param name="resolver">The VContainer object resolver.</param>
|
|
66
|
+
/// <param name="component">The component instance to inject and hydrate.</param>
|
|
67
|
+
/// <returns>The same component instance.</returns>
|
|
68
|
+
public static T InjectWithRelations<T>(this IObjectResolver resolver, T component)
|
|
69
|
+
where T : Component
|
|
70
|
+
{
|
|
71
|
+
if (component == null)
|
|
72
|
+
{
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Use Inject for compatibility with VContainer 1.16.x
|
|
77
|
+
resolver?.Inject(component);
|
|
78
|
+
resolver.AssignRelationalComponents(component);
|
|
79
|
+
return component;
|
|
80
|
+
}
|
|
81
|
+
|
|
59
82
|
/// <summary>
|
|
60
83
|
/// Assigns all relational fields on a component using the container's registered
|
|
61
84
|
/// <see cref="IRelationalComponentAssigner"/> if present, with a safe fallback to the
|
|
@@ -167,6 +190,79 @@ namespace WallstopStudios.UnityHelpers.Integrations.VContainer
|
|
|
167
190
|
return component;
|
|
168
191
|
}
|
|
169
192
|
|
|
193
|
+
/// <summary>
|
|
194
|
+
/// Instantiates a prefab that has component <typeparamref name="T"/> on the root, injects it
|
|
195
|
+
/// using VContainer and assigns relational fields.
|
|
196
|
+
/// </summary>
|
|
197
|
+
/// <typeparam name="T">Component type on the prefab root.</typeparam>
|
|
198
|
+
/// <param name="resolver">The VContainer object resolver.</param>
|
|
199
|
+
/// <param name="prefab">Prefab that contains <typeparamref name="T"/>.</param>
|
|
200
|
+
/// <param name="parent">Optional parent transform for the new instance.</param>
|
|
201
|
+
/// <returns>The instantiated component with DI and relational fields populated.</returns>
|
|
202
|
+
public static T InstantiateComponentWithRelations<T>(
|
|
203
|
+
this IObjectResolver resolver,
|
|
204
|
+
T prefab,
|
|
205
|
+
Transform parent = null
|
|
206
|
+
)
|
|
207
|
+
where T : Component
|
|
208
|
+
{
|
|
209
|
+
if (prefab == null)
|
|
210
|
+
{
|
|
211
|
+
throw new ArgumentNullException(nameof(prefab));
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
T instance = UnityEngine.Object.Instantiate(prefab, parent);
|
|
215
|
+
return resolver.BuildUpWithRelations(instance);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/// <summary>
|
|
219
|
+
/// Instantiates a GameObject prefab, injects its hierarchy with VContainer, then assigns
|
|
220
|
+
/// relational fields for all components beneath the root.
|
|
221
|
+
/// </summary>
|
|
222
|
+
/// <param name="resolver">The VContainer object resolver.</param>
|
|
223
|
+
/// <param name="prefab">GameObject prefab to instantiate.</param>
|
|
224
|
+
/// <param name="parent">Optional parent transform.</param>
|
|
225
|
+
/// <param name="includeInactiveChildren">Whether to include inactive children when assigning.</param>
|
|
226
|
+
/// <returns>The instantiated GameObject.</returns>
|
|
227
|
+
public static GameObject InstantiateGameObjectWithRelations(
|
|
228
|
+
this IObjectResolver resolver,
|
|
229
|
+
GameObject prefab,
|
|
230
|
+
Transform parent = null,
|
|
231
|
+
bool includeInactiveChildren = true
|
|
232
|
+
)
|
|
233
|
+
{
|
|
234
|
+
if (prefab == null)
|
|
235
|
+
{
|
|
236
|
+
throw new ArgumentNullException(nameof(prefab));
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
GameObject instance = UnityEngine.Object.Instantiate(prefab, parent);
|
|
240
|
+
resolver.InjectGameObjectWithRelations(instance, includeInactiveChildren);
|
|
241
|
+
return instance;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/// <summary>
|
|
245
|
+
/// Injects all components on <paramref name="root"/> and its children, then assigns
|
|
246
|
+
/// relational fields for the hierarchy.
|
|
247
|
+
/// </summary>
|
|
248
|
+
/// <param name="resolver">The VContainer object resolver.</param>
|
|
249
|
+
/// <param name="root">Root GameObject to inject and hydrate.</param>
|
|
250
|
+
/// <param name="includeInactiveChildren">Whether to include inactive children when assigning.</param>
|
|
251
|
+
public static void InjectGameObjectWithRelations(
|
|
252
|
+
this IObjectResolver resolver,
|
|
253
|
+
GameObject root,
|
|
254
|
+
bool includeInactiveChildren = true
|
|
255
|
+
)
|
|
256
|
+
{
|
|
257
|
+
if (root == null)
|
|
258
|
+
{
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
resolver?.InjectGameObject(root);
|
|
263
|
+
resolver.AssignRelationalHierarchy(root, includeInactiveChildren);
|
|
264
|
+
}
|
|
265
|
+
|
|
170
266
|
private static bool TryResolveAssigner(
|
|
171
267
|
IObjectResolver resolver,
|
|
172
268
|
out IRelationalComponentAssigner assigner
|