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
|
@@ -50,6 +50,26 @@ namespace WallstopStudios.UnityHelpers.Integrations.Zenject
|
|
|
50
50
|
/// </example>
|
|
51
51
|
public static class DiContainerRelationalExtensions
|
|
52
52
|
{
|
|
53
|
+
/// <summary>
|
|
54
|
+
/// Injects <paramref name="component"/> with Zenject and assigns its relational fields.
|
|
55
|
+
/// </summary>
|
|
56
|
+
/// <typeparam name="T">The component type.</typeparam>
|
|
57
|
+
/// <param name="container">The Zenject container.</param>
|
|
58
|
+
/// <param name="component">The component instance to inject and hydrate.</param>
|
|
59
|
+
/// <returns>The same component instance.</returns>
|
|
60
|
+
public static T InjectWithRelations<T>(this DiContainer container, T component)
|
|
61
|
+
where T : Component
|
|
62
|
+
{
|
|
63
|
+
if (component == null)
|
|
64
|
+
{
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
container?.Inject(component);
|
|
69
|
+
container.AssignRelationalComponents(component);
|
|
70
|
+
return component;
|
|
71
|
+
}
|
|
72
|
+
|
|
53
73
|
/// <summary>
|
|
54
74
|
/// Assigns all relational fields on a component using the container-registered
|
|
55
75
|
/// <see cref="IRelationalComponentAssigner"/>, with a safe fallback to the non-DI path.
|
|
@@ -124,9 +144,9 @@ namespace WallstopStudios.UnityHelpers.Integrations.Zenject
|
|
|
124
144
|
out List<Component> components
|
|
125
145
|
);
|
|
126
146
|
root.GetComponentsInChildren(includeInactiveChildren, components);
|
|
127
|
-
|
|
147
|
+
foreach (Component component in components)
|
|
128
148
|
{
|
|
129
|
-
|
|
149
|
+
component.AssignRelationalComponents();
|
|
130
150
|
}
|
|
131
151
|
}
|
|
132
152
|
|
|
@@ -161,6 +181,53 @@ namespace WallstopStudios.UnityHelpers.Integrations.Zenject
|
|
|
161
181
|
return instance;
|
|
162
182
|
}
|
|
163
183
|
|
|
184
|
+
/// <summary>
|
|
185
|
+
/// Instantiates a GameObject prefab with Zenject, injects the hierarchy and assigns
|
|
186
|
+
/// relational fields across the new instance.
|
|
187
|
+
/// </summary>
|
|
188
|
+
/// <param name="container">The Zenject container.</param>
|
|
189
|
+
/// <param name="prefab">GameObject prefab.</param>
|
|
190
|
+
/// <param name="parent">Optional parent transform.</param>
|
|
191
|
+
/// <param name="includeInactiveChildren">Include inactive children when assigning.</param>
|
|
192
|
+
/// <returns>The instantiated GameObject.</returns>
|
|
193
|
+
public static GameObject InstantiateGameObjectWithRelations(
|
|
194
|
+
this DiContainer container,
|
|
195
|
+
GameObject prefab,
|
|
196
|
+
Transform parent = null,
|
|
197
|
+
bool includeInactiveChildren = true
|
|
198
|
+
)
|
|
199
|
+
{
|
|
200
|
+
if (prefab == null)
|
|
201
|
+
{
|
|
202
|
+
throw new ArgumentNullException(nameof(prefab));
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
GameObject instance = container.InstantiatePrefab(prefab, parent);
|
|
206
|
+
container.InjectGameObjectWithRelations(instance, includeInactiveChildren);
|
|
207
|
+
return instance;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/// <summary>
|
|
211
|
+
/// Injects all components on <paramref name="root"/> and children with Zenject, then assigns
|
|
212
|
+
/// relational fields across the hierarchy.
|
|
213
|
+
/// </summary>
|
|
214
|
+
/// <param name="container">The Zenject container.</param>
|
|
215
|
+
/// <param name="root">Root GameObject.</param>
|
|
216
|
+
/// <param name="includeInactiveChildren">Include inactive children when assigning.</param>
|
|
217
|
+
public static void InjectGameObjectWithRelations(
|
|
218
|
+
this DiContainer container,
|
|
219
|
+
GameObject root,
|
|
220
|
+
bool includeInactiveChildren = true
|
|
221
|
+
)
|
|
222
|
+
{
|
|
223
|
+
if (root == null)
|
|
224
|
+
{
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
container?.InjectGameObject(root);
|
|
228
|
+
container.AssignRelationalHierarchy(root, includeInactiveChildren);
|
|
229
|
+
}
|
|
230
|
+
|
|
164
231
|
private static IRelationalComponentAssigner ResolveAssigner(DiContainer container)
|
|
165
232
|
{
|
|
166
233
|
if (container == null)
|
|
@@ -65,40 +65,117 @@ namespace WallstopStudios.UnityHelpers.Integrations.Zenject
|
|
|
65
65
|
|
|
66
66
|
if (relationalTypes.Count == 0)
|
|
67
67
|
{
|
|
68
|
+
// Fallback: scan all components in the active scene and assign when type has relational fields
|
|
69
|
+
bool includeInactiveAll = _options.IncludeInactive;
|
|
70
|
+
Scene active = SceneManager.GetActiveScene();
|
|
71
|
+
Component[] allComponents = includeInactiveAll
|
|
72
|
+
? UnityEngine.Object.FindObjectsOfType<Component>(true)
|
|
73
|
+
: UnityEngine.Object.FindObjectsOfType<Component>(false);
|
|
74
|
+
|
|
75
|
+
for (int i = 0; i < allComponents.Length; i++)
|
|
76
|
+
{
|
|
77
|
+
Component c = allComponents[i];
|
|
78
|
+
if (c == null || c.gameObject.scene != active)
|
|
79
|
+
{
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (_assigner.HasRelationalAssignments(c.GetType()))
|
|
84
|
+
{
|
|
85
|
+
_assigner.Assign(c);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
68
88
|
return;
|
|
69
89
|
}
|
|
70
90
|
|
|
71
91
|
bool includeInactive = _options.IncludeInactive;
|
|
72
92
|
Scene activeScene = SceneManager.GetActiveScene();
|
|
73
93
|
|
|
74
|
-
|
|
94
|
+
if (_options.UseSinglePassScan)
|
|
75
95
|
{
|
|
76
|
-
|
|
96
|
+
using PooledResource<HashSet<Type>> pooledSet = Buffers<Type>.HashSet.Get(
|
|
97
|
+
out HashSet<Type> relationalSet
|
|
98
|
+
);
|
|
99
|
+
foreach (Type relationalType in relationalTypes)
|
|
77
100
|
{
|
|
78
|
-
|
|
101
|
+
if (relationalType != null)
|
|
102
|
+
{
|
|
103
|
+
relationalSet.Add(relationalType);
|
|
104
|
+
}
|
|
79
105
|
}
|
|
80
106
|
|
|
81
|
-
|
|
82
|
-
? UnityEngine.Object.FindObjectsOfType(
|
|
83
|
-
: UnityEngine.Object.FindObjectsOfType(
|
|
107
|
+
Component[] all = includeInactive
|
|
108
|
+
? UnityEngine.Object.FindObjectsOfType<Component>(true)
|
|
109
|
+
: UnityEngine.Object.FindObjectsOfType<Component>(false);
|
|
110
|
+
|
|
111
|
+
foreach (Component c in all)
|
|
112
|
+
{
|
|
113
|
+
if (c == null || c.gameObject.scene != activeScene)
|
|
114
|
+
{
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
84
117
|
|
|
85
|
-
|
|
118
|
+
Type t = c.GetType();
|
|
119
|
+
while (t != null && typeof(Component).IsAssignableFrom(t))
|
|
120
|
+
{
|
|
121
|
+
if (relationalSet.Contains(t))
|
|
122
|
+
{
|
|
123
|
+
_assigner.Assign(c);
|
|
124
|
+
break;
|
|
125
|
+
}
|
|
126
|
+
t = t.BaseType;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
else
|
|
131
|
+
{
|
|
132
|
+
foreach (Type componentType in relationalTypes)
|
|
86
133
|
{
|
|
87
|
-
if (
|
|
134
|
+
if (componentType == null)
|
|
88
135
|
{
|
|
89
136
|
continue;
|
|
90
137
|
}
|
|
91
138
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
139
|
+
UnityEngine.Object[] located = includeInactive
|
|
140
|
+
? UnityEngine.Object.FindObjectsOfType(componentType, true)
|
|
141
|
+
: UnityEngine.Object.FindObjectsOfType(componentType, false);
|
|
142
|
+
|
|
143
|
+
foreach (UnityEngine.Object candidate in located)
|
|
144
|
+
{
|
|
145
|
+
if (candidate is not Component component)
|
|
146
|
+
{
|
|
147
|
+
continue;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
if (component == null || component.gameObject.scene != activeScene)
|
|
151
|
+
{
|
|
152
|
+
continue;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
_assigner.Assign(component);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// Safety net in Editor/tests: also walk scene roots to ensure coverage
|
|
161
|
+
#if UNITY_EDITOR
|
|
162
|
+
if (!Application.isPlaying)
|
|
163
|
+
{
|
|
164
|
+
using PooledResource<List<GameObject>> rootGoBuffer = Buffers<GameObject>.List.Get(
|
|
165
|
+
out List<GameObject> roots
|
|
166
|
+
);
|
|
167
|
+
activeScene.GetRootGameObjects(roots);
|
|
168
|
+
foreach (GameObject root in roots)
|
|
169
|
+
{
|
|
170
|
+
if (root == null)
|
|
95
171
|
{
|
|
96
172
|
continue;
|
|
97
173
|
}
|
|
98
174
|
|
|
99
|
-
_assigner.
|
|
175
|
+
_assigner.AssignHierarchy(root, includeInactive);
|
|
100
176
|
}
|
|
101
177
|
}
|
|
178
|
+
#endif
|
|
102
179
|
}
|
|
103
180
|
}
|
|
104
181
|
}
|
|
@@ -12,9 +12,13 @@ namespace WallstopStudios.UnityHelpers.Integrations.Zenject
|
|
|
12
12
|
/// </summary>
|
|
13
13
|
/// <remarks>
|
|
14
14
|
/// Add this installer to your <c>SceneContext</c> to:
|
|
15
|
-
/// - Bind <see cref="IRelationalComponentAssigner"/> as a singleton
|
|
15
|
+
/// - Bind <see cref="IRelationalComponentAssigner"/> as a singleton (if nobody else already did)
|
|
16
16
|
/// - Optionally register <see cref="RelationalComponentSceneInitializer"/> to populate relational
|
|
17
17
|
/// fields after container construction
|
|
18
|
+
/// - Optionally register <see cref="RelationalSceneLoadListener"/> so additively loaded scenes
|
|
19
|
+
/// receive the same hydration pass
|
|
20
|
+
/// Serialized toggles expose these behaviours plus the shared
|
|
21
|
+
/// <see cref="RelationalSceneAssignmentOptions"/> (include inactive objects, scan strategy).
|
|
18
22
|
/// </remarks>
|
|
19
23
|
/// <example>
|
|
20
24
|
/// <code>
|
|
@@ -39,6 +43,13 @@ namespace WallstopStudios.UnityHelpers.Integrations.Zenject
|
|
|
39
43
|
)]
|
|
40
44
|
private bool _includeInactiveObjects = true;
|
|
41
45
|
|
|
46
|
+
[SerializeField]
|
|
47
|
+
[Tooltip(
|
|
48
|
+
"When enabled, registers a listener that assigns relational fields for additively loaded"
|
|
49
|
+
+ " scenes as they are loaded."
|
|
50
|
+
)]
|
|
51
|
+
private bool _listenForAdditiveScenes = true;
|
|
52
|
+
|
|
42
53
|
public override void InstallBindings()
|
|
43
54
|
{
|
|
44
55
|
AttributeMetadataCache cacheInstance = AttributeMetadataCache.Instance;
|
|
@@ -66,6 +77,17 @@ namespace WallstopStudios.UnityHelpers.Integrations.Zenject
|
|
|
66
77
|
|
|
67
78
|
Container.BindInterfacesTo<RelationalComponentSceneInitializer>().AsSingle();
|
|
68
79
|
}
|
|
80
|
+
|
|
81
|
+
if (_listenForAdditiveScenes)
|
|
82
|
+
{
|
|
83
|
+
if (!Container.HasBinding(typeof(RelationalSceneAssignmentOptions)))
|
|
84
|
+
{
|
|
85
|
+
Container.BindInstance(
|
|
86
|
+
new RelationalSceneAssignmentOptions(_includeInactiveObjects)
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
Container.BindInterfacesTo<RelationalSceneLoadListener>().AsSingle();
|
|
90
|
+
}
|
|
69
91
|
}
|
|
70
92
|
}
|
|
71
93
|
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
#if ZENJECT_PRESENT
|
|
2
|
+
namespace WallstopStudios.UnityHelpers.Integrations.Zenject
|
|
3
|
+
{
|
|
4
|
+
using global::Zenject;
|
|
5
|
+
using UnityEngine;
|
|
6
|
+
|
|
7
|
+
/// <summary>
|
|
8
|
+
/// MemoryPool that assigns relational fields for spawned items automatically.
|
|
9
|
+
/// </summary>
|
|
10
|
+
/// <typeparam name="TValue">Component type managed by the pool.</typeparam>
|
|
11
|
+
public class RelationalMemoryPool<TValue> : MemoryPool<TValue>
|
|
12
|
+
where TValue : Component
|
|
13
|
+
{
|
|
14
|
+
[Inject]
|
|
15
|
+
internal DiContainer _container = null;
|
|
16
|
+
|
|
17
|
+
protected override void OnSpawned(TValue item)
|
|
18
|
+
{
|
|
19
|
+
base.OnSpawned(item);
|
|
20
|
+
_container.AssignRelationalComponents(item);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
internal void InternalOnSpawned(TValue item) => OnSpawned(item);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/// <summary>
|
|
27
|
+
/// MemoryPool with one spawn parameter that assigns relational fields for spawned items.
|
|
28
|
+
/// </summary>
|
|
29
|
+
/// <typeparam name="TParam1">Spawn parameter type.</typeparam>
|
|
30
|
+
/// <typeparam name="TValue">Component type managed by the pool.</typeparam>
|
|
31
|
+
public class RelationalMemoryPool<TParam1, TValue> : MemoryPool<TParam1, TValue>
|
|
32
|
+
where TValue : Component
|
|
33
|
+
{
|
|
34
|
+
[Inject]
|
|
35
|
+
internal DiContainer _container = null;
|
|
36
|
+
|
|
37
|
+
protected override void Reinitialize(TParam1 p1, TValue item)
|
|
38
|
+
{
|
|
39
|
+
base.Reinitialize(p1, item);
|
|
40
|
+
_container.AssignRelationalComponents(item);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
#endif
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
namespace WallstopStudios.UnityHelpers.Integrations.Zenject
|
|
3
3
|
{
|
|
4
4
|
using System;
|
|
5
|
+
using WallstopStudios.UnityHelpers.Core.Helper;
|
|
5
6
|
|
|
6
7
|
/// <summary>
|
|
7
8
|
/// Controls how the Zenject integration scans the scene for relational components.
|
|
@@ -22,25 +23,36 @@ namespace WallstopStudios.UnityHelpers.Integrations.Zenject
|
|
|
22
23
|
/// When true the initializer will scan inactive scene objects so that relational fields are
|
|
23
24
|
/// populated even for disabled hierarchies. Defaults to <c>true</c>.
|
|
24
25
|
/// </param>
|
|
25
|
-
|
|
26
|
+
/// <param name="useSinglePassScan">
|
|
27
|
+
/// When true uses a single-pass scene scan for performance (recommended). Defaults to
|
|
28
|
+
/// <c>true</c>.
|
|
29
|
+
/// </param>
|
|
30
|
+
public RelationalSceneAssignmentOptions(bool includeInactive, bool useSinglePassScan = true)
|
|
26
31
|
{
|
|
27
32
|
IncludeInactive = includeInactive;
|
|
33
|
+
UseSinglePassScan = useSinglePassScan;
|
|
28
34
|
}
|
|
29
35
|
|
|
30
36
|
/// <summary>
|
|
31
37
|
/// Options used when no explicit configuration is supplied.
|
|
32
38
|
/// </summary>
|
|
33
|
-
public static RelationalSceneAssignmentOptions Default => new(
|
|
39
|
+
public static RelationalSceneAssignmentOptions Default => new(true, true);
|
|
34
40
|
|
|
35
41
|
/// <summary>
|
|
36
42
|
/// Gets whether inactive GameObjects should be included when scanning the scene.
|
|
37
43
|
/// </summary>
|
|
38
44
|
public bool IncludeInactive { get; }
|
|
39
45
|
|
|
46
|
+
/// <summary>
|
|
47
|
+
/// Gets whether to use a single-pass scene scan to locate relational components.
|
|
48
|
+
/// </summary>
|
|
49
|
+
public bool UseSinglePassScan { get; }
|
|
50
|
+
|
|
40
51
|
/// <inheritdoc />
|
|
41
52
|
public bool Equals(RelationalSceneAssignmentOptions other)
|
|
42
53
|
{
|
|
43
|
-
return IncludeInactive == other.IncludeInactive
|
|
54
|
+
return IncludeInactive == other.IncludeInactive
|
|
55
|
+
&& UseSinglePassScan == other.UseSinglePassScan;
|
|
44
56
|
}
|
|
45
57
|
|
|
46
58
|
/// <inheritdoc />
|
|
@@ -52,12 +64,9 @@ namespace WallstopStudios.UnityHelpers.Integrations.Zenject
|
|
|
52
64
|
/// <inheritdoc />
|
|
53
65
|
public override int GetHashCode()
|
|
54
66
|
{
|
|
55
|
-
return
|
|
67
|
+
return Objects.HashCode(IncludeInactive, UseSinglePassScan);
|
|
56
68
|
}
|
|
57
69
|
|
|
58
|
-
/// <summary>
|
|
59
|
-
/// Equality operator.
|
|
60
|
-
/// </summary>
|
|
61
70
|
/// <summary>
|
|
62
71
|
/// Equality operator.
|
|
63
72
|
/// </summary>
|
|
@@ -69,9 +78,6 @@ namespace WallstopStudios.UnityHelpers.Integrations.Zenject
|
|
|
69
78
|
return left.Equals(right);
|
|
70
79
|
}
|
|
71
80
|
|
|
72
|
-
/// <summary>
|
|
73
|
-
/// Inequality operator.
|
|
74
|
-
/// </summary>
|
|
75
81
|
/// <summary>
|
|
76
82
|
/// Inequality operator.
|
|
77
83
|
/// </summary>
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
#if ZENJECT_PRESENT
|
|
2
|
+
namespace WallstopStudios.UnityHelpers.Integrations.Zenject
|
|
3
|
+
{
|
|
4
|
+
using System;
|
|
5
|
+
using System.Collections.Generic;
|
|
6
|
+
using global::Zenject;
|
|
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
|
+
/// <summary>
|
|
14
|
+
/// Listens for additive scene loads and assigns relational fields within the newly loaded scene.
|
|
15
|
+
/// </summary>
|
|
16
|
+
public sealed class RelationalSceneLoadListener : IInitializable, IDisposable
|
|
17
|
+
{
|
|
18
|
+
private readonly IRelationalComponentAssigner _assigner;
|
|
19
|
+
private readonly AttributeMetadataCache _metadataCache;
|
|
20
|
+
private readonly RelationalSceneAssignmentOptions _options;
|
|
21
|
+
|
|
22
|
+
public RelationalSceneLoadListener(
|
|
23
|
+
IRelationalComponentAssigner assigner,
|
|
24
|
+
AttributeMetadataCache metadataCache,
|
|
25
|
+
RelationalSceneAssignmentOptions options
|
|
26
|
+
)
|
|
27
|
+
{
|
|
28
|
+
_assigner = assigner ?? throw new ArgumentNullException(nameof(assigner));
|
|
29
|
+
_metadataCache = metadataCache;
|
|
30
|
+
_options = options;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
public void Initialize()
|
|
34
|
+
{
|
|
35
|
+
SceneManager.sceneLoaded += OnSceneLoaded;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
public void Dispose()
|
|
39
|
+
{
|
|
40
|
+
SceneManager.sceneLoaded -= OnSceneLoaded;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
internal void OnSceneLoaded(Scene scene, LoadSceneMode mode)
|
|
44
|
+
{
|
|
45
|
+
if (!scene.IsValid())
|
|
46
|
+
{
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
AttributeMetadataCache cache = _metadataCache ?? AttributeMetadataCache.Instance;
|
|
51
|
+
if (cache == null)
|
|
52
|
+
{
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
using PooledResource<List<Type>> pooledTypes = Buffers<Type>.List.Get(
|
|
57
|
+
out List<Type> relationalTypes
|
|
58
|
+
);
|
|
59
|
+
cache.CollectRelationalComponentTypes(relationalTypes);
|
|
60
|
+
|
|
61
|
+
if (relationalTypes.Count == 0)
|
|
62
|
+
{
|
|
63
|
+
// Fallback: scan all components in new scene and assign when type has relational fields
|
|
64
|
+
bool includeInactiveAll = _options.IncludeInactive;
|
|
65
|
+
Component[] all = includeInactiveAll
|
|
66
|
+
? UnityEngine.Object.FindObjectsOfType<Component>(true)
|
|
67
|
+
: UnityEngine.Object.FindObjectsOfType<Component>(false);
|
|
68
|
+
|
|
69
|
+
for (int i = 0; i < all.Length; i++)
|
|
70
|
+
{
|
|
71
|
+
Component c = all[i];
|
|
72
|
+
if (c == null || c.gameObject.scene != scene)
|
|
73
|
+
{
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (_assigner.HasRelationalAssignments(c.GetType()))
|
|
78
|
+
{
|
|
79
|
+
_assigner.Assign(c);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
bool includeInactive = _options.IncludeInactive;
|
|
86
|
+
|
|
87
|
+
if (_options.UseSinglePassScan)
|
|
88
|
+
{
|
|
89
|
+
AssignBySinglePass(scene, relationalTypes, includeInactive);
|
|
90
|
+
}
|
|
91
|
+
else
|
|
92
|
+
{
|
|
93
|
+
AssignByTypePass(scene, relationalTypes, includeInactive);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// Safety net in Editor/tests: also walk scene roots
|
|
97
|
+
#if UNITY_EDITOR
|
|
98
|
+
if (!Application.isPlaying)
|
|
99
|
+
{
|
|
100
|
+
AssignBySceneRoots(scene, includeInactive);
|
|
101
|
+
|
|
102
|
+
// In EditMode, some components may be registered on the following editor tick.
|
|
103
|
+
// Schedule a delayed pass to ensure complete hydration in tests/tools.
|
|
104
|
+
UnityEditor.EditorApplication.delayCall += () =>
|
|
105
|
+
{
|
|
106
|
+
if (scene.IsValid())
|
|
107
|
+
{
|
|
108
|
+
AssignBySceneRoots(scene, includeInactive);
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
#endif
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
private void AssignByTypePass(
|
|
116
|
+
Scene target,
|
|
117
|
+
List<Type> relationalTypes,
|
|
118
|
+
bool includeInactive
|
|
119
|
+
)
|
|
120
|
+
{
|
|
121
|
+
using PooledResource<List<GameObject>> rootGoBuffer = Buffers<GameObject>.List.Get(
|
|
122
|
+
out List<GameObject> roots
|
|
123
|
+
);
|
|
124
|
+
target.GetRootGameObjects(roots);
|
|
125
|
+
if (roots.Count == 0)
|
|
126
|
+
{
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
using PooledResource<HashSet<Type>> typeSetPool = Buffers<Type>.HashSet.Get(
|
|
131
|
+
out HashSet<Type> relationalSet
|
|
132
|
+
);
|
|
133
|
+
for (int i = 0; i < relationalTypes.Count; i++)
|
|
134
|
+
{
|
|
135
|
+
Type type = relationalTypes[i];
|
|
136
|
+
if (type != null)
|
|
137
|
+
{
|
|
138
|
+
relationalSet.Add(type);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
using PooledResource<List<Component>> componentBuffer = Buffers<Component>.List.Get(
|
|
143
|
+
out List<Component> components
|
|
144
|
+
);
|
|
145
|
+
|
|
146
|
+
for (int i = 0; i < roots.Count; i++)
|
|
147
|
+
{
|
|
148
|
+
GameObject root = roots[i];
|
|
149
|
+
if (root == null)
|
|
150
|
+
{
|
|
151
|
+
continue;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
root.GetComponentsInChildren(includeInactive, components);
|
|
155
|
+
for (int j = 0; j < components.Count; j++)
|
|
156
|
+
{
|
|
157
|
+
Component component = components[j];
|
|
158
|
+
if (component == null || component.gameObject.scene != target)
|
|
159
|
+
{
|
|
160
|
+
continue;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
Type current = component.GetType();
|
|
164
|
+
while (current != null && typeof(Component).IsAssignableFrom(current))
|
|
165
|
+
{
|
|
166
|
+
if (relationalSet.Contains(current))
|
|
167
|
+
{
|
|
168
|
+
_assigner.Assign(component);
|
|
169
|
+
break;
|
|
170
|
+
}
|
|
171
|
+
current = current.BaseType;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
components.Clear();
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
private void AssignBySinglePass(
|
|
180
|
+
Scene target,
|
|
181
|
+
List<Type> relationalTypes,
|
|
182
|
+
bool includeInactive
|
|
183
|
+
)
|
|
184
|
+
{
|
|
185
|
+
using PooledResource<HashSet<Type>> pooledSet = Buffers<Type>.HashSet.Get(
|
|
186
|
+
out HashSet<Type> relationalSet
|
|
187
|
+
);
|
|
188
|
+
for (int i = 0; i < relationalTypes.Count; i++)
|
|
189
|
+
{
|
|
190
|
+
if (relationalTypes[i] != null)
|
|
191
|
+
{
|
|
192
|
+
relationalSet.Add(relationalTypes[i]);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
Component[] all = includeInactive
|
|
197
|
+
? UnityEngine.Object.FindObjectsOfType<Component>(true)
|
|
198
|
+
: UnityEngine.Object.FindObjectsOfType<Component>(false);
|
|
199
|
+
|
|
200
|
+
for (int i = 0; i < all.Length; i++)
|
|
201
|
+
{
|
|
202
|
+
Component component = all[i];
|
|
203
|
+
if (component == null || component.gameObject.scene != target)
|
|
204
|
+
{
|
|
205
|
+
continue;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
Type t = component.GetType();
|
|
209
|
+
while (t != null && typeof(Component).IsAssignableFrom(t))
|
|
210
|
+
{
|
|
211
|
+
if (relationalSet.Contains(t))
|
|
212
|
+
{
|
|
213
|
+
_assigner.Assign(component);
|
|
214
|
+
break;
|
|
215
|
+
}
|
|
216
|
+
t = t.BaseType;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
private void AssignBySceneRoots(Scene target, bool includeInactive)
|
|
222
|
+
{
|
|
223
|
+
int rootCount = target.rootCount;
|
|
224
|
+
if (rootCount == 0)
|
|
225
|
+
{
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
using PooledResource<List<GameObject>> rootGoBuffer = Buffers<GameObject>.List.Get(
|
|
229
|
+
out List<GameObject> roots
|
|
230
|
+
);
|
|
231
|
+
target.GetRootGameObjects(roots);
|
|
232
|
+
foreach (GameObject root in roots)
|
|
233
|
+
{
|
|
234
|
+
if (root == null)
|
|
235
|
+
{
|
|
236
|
+
continue;
|
|
237
|
+
}
|
|
238
|
+
_assigner.AssignHierarchy(root, includeInactive);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
#endif
|
|
@@ -227,10 +227,7 @@ namespace WallstopStudios.UnityHelpers.Tags
|
|
|
227
227
|
if (inst != null && inst._prewarmRelationalOnLoad)
|
|
228
228
|
{
|
|
229
229
|
RelationalComponentInitializer.Report report =
|
|
230
|
-
|
|
231
|
-
types: null,
|
|
232
|
-
logSummary: false
|
|
233
|
-
);
|
|
230
|
+
RelationalComponentInitializer.Initialize(types: null, logSummary: false);
|
|
234
231
|
Debug.Log(
|
|
235
232
|
$"AttributeMetadataCache: Relational prewarm enabled. TypesWarmed={report.TypesWarmed}, FieldsWarmed={report.FieldsWarmed}, Warnings={report.Warnings}, Errors={report.Errors}."
|
|
236
233
|
);
|