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,247 @@
|
|
|
1
|
+
namespace WallstopStudios.UnityHelpers.Tests.Serialization
|
|
2
|
+
{
|
|
3
|
+
using System;
|
|
4
|
+
using System.Collections.Generic;
|
|
5
|
+
using System.Text;
|
|
6
|
+
using System.Text.Json;
|
|
7
|
+
using NUnit.Framework;
|
|
8
|
+
using UnityEngine;
|
|
9
|
+
using UnityEngine.TestTools;
|
|
10
|
+
using WallstopStudios.UnityHelpers.Core.Helper;
|
|
11
|
+
using WallstopStudios.UnityHelpers.Core.Serialization;
|
|
12
|
+
using WallstopStudios.UnityHelpers.Tests.TestUtils;
|
|
13
|
+
|
|
14
|
+
[TestFixture]
|
|
15
|
+
public sealed class UnityEngineObjectJsonTests : CommonTestBase
|
|
16
|
+
{
|
|
17
|
+
[Test]
|
|
18
|
+
public void GameObjectSerializationContainsExpectedFields()
|
|
19
|
+
{
|
|
20
|
+
GameObject go = Track(new GameObject("GO_Main"));
|
|
21
|
+
int expectedId = go.GetInstanceID();
|
|
22
|
+
string json = Serializer.JsonStringify(go);
|
|
23
|
+
Assert.IsFalse(string.IsNullOrWhiteSpace(json), json);
|
|
24
|
+
|
|
25
|
+
using JsonDocument doc = JsonDocument.Parse(json);
|
|
26
|
+
JsonElement root = doc.RootElement;
|
|
27
|
+
Assert.AreEqual(JsonValueKind.Object, root.ValueKind);
|
|
28
|
+
Assert.True(root.TryGetProperty("name", out JsonElement name));
|
|
29
|
+
Assert.True(root.TryGetProperty("type", out JsonElement type));
|
|
30
|
+
Assert.True(root.TryGetProperty("instanceId", out JsonElement id));
|
|
31
|
+
Assert.AreEqual("GO_Main", name.GetString());
|
|
32
|
+
StringAssert.Contains("UnityEngine.GameObject", type.GetString());
|
|
33
|
+
Assert.AreEqual(expectedId, id.GetInt32());
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
[Test]
|
|
37
|
+
public void GameObjectSerializationHandlesQuotesAndEscapes()
|
|
38
|
+
{
|
|
39
|
+
string tricky = "Quote \" and Backslash \\ and Newline\n and Unicode ☺";
|
|
40
|
+
GameObject go = Track(new GameObject(tricky));
|
|
41
|
+
string json = Serializer.JsonStringify(go);
|
|
42
|
+
using JsonDocument doc = JsonDocument.Parse(json);
|
|
43
|
+
Assert.AreEqual(tricky, doc.RootElement.GetProperty("name").GetString());
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
[Test]
|
|
47
|
+
public void ObjectTypedSerializationUsesRuntimeTypeConverter()
|
|
48
|
+
{
|
|
49
|
+
GameObject go = Track(new GameObject("ObjectTypedGO"));
|
|
50
|
+
int expectedId = go.GetInstanceID();
|
|
51
|
+
object goAsObject = go;
|
|
52
|
+
string json = Serializer.JsonStringify(goAsObject);
|
|
53
|
+
using JsonDocument doc = JsonDocument.Parse(json);
|
|
54
|
+
JsonElement root = doc.RootElement;
|
|
55
|
+
Assert.AreEqual("ObjectTypedGO", root.GetProperty("name").GetString());
|
|
56
|
+
StringAssert.Contains("UnityEngine.GameObject", root.GetProperty("type").GetString());
|
|
57
|
+
Assert.AreEqual(expectedId, root.GetProperty("instanceId").GetInt32());
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
[Test]
|
|
61
|
+
public void GameObjectSerializationPrettyPrintFormatsAndParses()
|
|
62
|
+
{
|
|
63
|
+
GameObject go = Track(new GameObject("Pretty ☃ Object ✓"));
|
|
64
|
+
int expectedId = go.GetInstanceID();
|
|
65
|
+
string json = Serializer.JsonStringify(go, pretty: true);
|
|
66
|
+
Assert.IsFalse(string.IsNullOrWhiteSpace(json), json);
|
|
67
|
+
StringAssert.Contains("\n", json);
|
|
68
|
+
|
|
69
|
+
using JsonDocument doc = JsonDocument.Parse(json);
|
|
70
|
+
JsonElement root = doc.RootElement;
|
|
71
|
+
Assert.True(root.TryGetProperty("name", out JsonElement name));
|
|
72
|
+
Assert.AreEqual("Pretty ☃ Object ✓", name.GetString());
|
|
73
|
+
Assert.True(root.TryGetProperty("instanceId", out JsonElement id));
|
|
74
|
+
Assert.AreEqual(expectedId, id.GetInt32());
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
[Test]
|
|
78
|
+
public void GameObjectSerializationStableInstanceIdAcrossSerializations()
|
|
79
|
+
{
|
|
80
|
+
GameObject go = Track(new GameObject("StableId"));
|
|
81
|
+
int expectedId = go.GetInstanceID();
|
|
82
|
+
string j1 = Serializer.JsonStringify(go);
|
|
83
|
+
string j2 = Serializer.JsonStringify(go);
|
|
84
|
+
|
|
85
|
+
using JsonDocument d1 = JsonDocument.Parse(j1);
|
|
86
|
+
using JsonDocument d2 = JsonDocument.Parse(j2);
|
|
87
|
+
int id1 = d1.RootElement.GetProperty("instanceId").GetInt32();
|
|
88
|
+
int id2 = d2.RootElement.GetProperty("instanceId").GetInt32();
|
|
89
|
+
Assert.AreEqual(expectedId, id1);
|
|
90
|
+
Assert.AreEqual(id1, id2);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
[Test]
|
|
94
|
+
public void GameObjectDeserializationIsNotSupported()
|
|
95
|
+
{
|
|
96
|
+
GameObject go = Track(new GameObject("NoReadSupport"));
|
|
97
|
+
string json = Serializer.JsonStringify(go);
|
|
98
|
+
|
|
99
|
+
// Our converter intentionally does not implement Read. Ensure this throws.
|
|
100
|
+
Assert.Throws<NotImplementedException>(() =>
|
|
101
|
+
Serializer.JsonDeserialize<GameObject>(json)
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
[UnityTest]
|
|
106
|
+
public System.Collections.IEnumerator GameObjectArraySerializationWorksWithNullAndDestroyed()
|
|
107
|
+
{
|
|
108
|
+
GameObject alive = Track(new GameObject("Alive"));
|
|
109
|
+
int aliveId = alive.GetInstanceID();
|
|
110
|
+
GameObject dead = Track(new GameObject("Dead"));
|
|
111
|
+
dead.Destroy();
|
|
112
|
+
yield return null; // ensure Unity nullification
|
|
113
|
+
Assert.IsTrue(dead == null);
|
|
114
|
+
|
|
115
|
+
GameObject[] data = { null, alive, dead };
|
|
116
|
+
string json = Serializer.JsonStringify(data);
|
|
117
|
+
Assert.IsFalse(string.IsNullOrWhiteSpace(json), json);
|
|
118
|
+
|
|
119
|
+
using JsonDocument doc = JsonDocument.Parse(json);
|
|
120
|
+
JsonElement root = doc.RootElement;
|
|
121
|
+
Assert.AreEqual(JsonValueKind.Array, root.ValueKind);
|
|
122
|
+
Assert.AreEqual(3, root.GetArrayLength());
|
|
123
|
+
Assert.AreEqual(JsonValueKind.Null, root[0].ValueKind);
|
|
124
|
+
|
|
125
|
+
JsonElement mid = root[1];
|
|
126
|
+
Assert.AreEqual(JsonValueKind.Object, mid.ValueKind);
|
|
127
|
+
Assert.AreEqual("Alive", mid.GetProperty("name").GetString());
|
|
128
|
+
Assert.AreEqual(aliveId, mid.GetProperty("instanceId").GetInt32());
|
|
129
|
+
|
|
130
|
+
Assert.AreEqual(JsonValueKind.Null, root[2].ValueKind);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
[UnityTest]
|
|
134
|
+
public System.Collections.IEnumerator GameObjectDictionarySerializationWorksWithNullAndDestroyed()
|
|
135
|
+
{
|
|
136
|
+
GameObject alive = Track(new GameObject("Alive_Dict"));
|
|
137
|
+
int aliveId = alive.GetInstanceID();
|
|
138
|
+
GameObject dead = Track(new GameObject("Dead_Dict"));
|
|
139
|
+
dead.Destroy();
|
|
140
|
+
yield return null; // ensure Unity nullification
|
|
141
|
+
Assert.IsTrue(dead == null);
|
|
142
|
+
|
|
143
|
+
Dictionary<string, GameObject> dict = new()
|
|
144
|
+
{
|
|
145
|
+
["none"] = null,
|
|
146
|
+
["alive"] = alive,
|
|
147
|
+
["dead"] = dead,
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
string json = Serializer.JsonStringify(dict);
|
|
151
|
+
Assert.IsFalse(string.IsNullOrWhiteSpace(json), json);
|
|
152
|
+
|
|
153
|
+
using JsonDocument doc = JsonDocument.Parse(json);
|
|
154
|
+
JsonElement root = doc.RootElement;
|
|
155
|
+
Assert.AreEqual(JsonValueKind.Object, root.ValueKind);
|
|
156
|
+
|
|
157
|
+
Assert.True(root.TryGetProperty("none", out JsonElement none));
|
|
158
|
+
Assert.AreEqual(JsonValueKind.Null, none.ValueKind);
|
|
159
|
+
|
|
160
|
+
Assert.True(root.TryGetProperty("alive", out JsonElement aliveEl));
|
|
161
|
+
Assert.AreEqual("Alive_Dict", aliveEl.GetProperty("name").GetString());
|
|
162
|
+
Assert.AreEqual(aliveId, aliveEl.GetProperty("instanceId").GetInt32());
|
|
163
|
+
|
|
164
|
+
Assert.True(root.TryGetProperty("dead", out JsonElement deadEl));
|
|
165
|
+
Assert.AreEqual(JsonValueKind.Null, deadEl.ValueKind);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
private sealed class GoHolder
|
|
169
|
+
{
|
|
170
|
+
public GameObject Go { get; set; }
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
private sealed class GoFieldHolder
|
|
174
|
+
{
|
|
175
|
+
public GameObject go;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
[Test]
|
|
179
|
+
public void NestedObjectSerializationWithGameObjectProperty()
|
|
180
|
+
{
|
|
181
|
+
GameObject go = Track(new GameObject("Nested"));
|
|
182
|
+
int expectedId = go.GetInstanceID();
|
|
183
|
+
GoHolder holder = new() { Go = go };
|
|
184
|
+
string json = Serializer.JsonStringify(holder);
|
|
185
|
+
Assert.IsFalse(string.IsNullOrWhiteSpace(json), json);
|
|
186
|
+
|
|
187
|
+
using JsonDocument doc = JsonDocument.Parse(json);
|
|
188
|
+
JsonElement root = doc.RootElement;
|
|
189
|
+
Assert.True(root.TryGetProperty("Go", out JsonElement goEl));
|
|
190
|
+
Assert.AreEqual("Nested", goEl.GetProperty("name").GetString());
|
|
191
|
+
Assert.AreEqual(expectedId, goEl.GetProperty("instanceId").GetInt32());
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
[Test]
|
|
195
|
+
public void NestedObjectSerializationWithGameObjectField()
|
|
196
|
+
{
|
|
197
|
+
GameObject go = Track(new GameObject("NestedField"));
|
|
198
|
+
int expectedId = go.GetInstanceID();
|
|
199
|
+
GoFieldHolder holder = new() { go = go };
|
|
200
|
+
string json = Serializer.JsonStringify(holder);
|
|
201
|
+
Assert.IsFalse(string.IsNullOrWhiteSpace(json), json);
|
|
202
|
+
|
|
203
|
+
using JsonDocument doc = JsonDocument.Parse(json);
|
|
204
|
+
JsonElement root = doc.RootElement;
|
|
205
|
+
Assert.True(root.TryGetProperty("go", out JsonElement goEl));
|
|
206
|
+
Assert.AreEqual("NestedField", goEl.GetProperty("name").GetString());
|
|
207
|
+
Assert.AreEqual(expectedId, goEl.GetProperty("instanceId").GetInt32());
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
[Test]
|
|
211
|
+
public void FastSerializerProducesValidGameObjectJson()
|
|
212
|
+
{
|
|
213
|
+
GameObject go = Track(new GameObject("FastGO"));
|
|
214
|
+
int expectedId = go.GetInstanceID();
|
|
215
|
+
byte[] bytes = Serializer.JsonSerializeFast(go);
|
|
216
|
+
Assert.NotNull(bytes);
|
|
217
|
+
string json = Encoding.UTF8.GetString(bytes);
|
|
218
|
+
Assert.IsFalse(string.IsNullOrWhiteSpace(json), json);
|
|
219
|
+
|
|
220
|
+
using JsonDocument doc = JsonDocument.Parse(json);
|
|
221
|
+
JsonElement root = doc.RootElement;
|
|
222
|
+
Assert.AreEqual("FastGO", root.GetProperty("name").GetString());
|
|
223
|
+
Assert.AreEqual(expectedId, root.GetProperty("instanceId").GetInt32());
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
[Test]
|
|
227
|
+
public void SerializeIntoCallerBufferProducesValidGameObjectJson()
|
|
228
|
+
{
|
|
229
|
+
GameObject go = Track(new GameObject("BufferedGO"));
|
|
230
|
+
int expectedId = go.GetInstanceID();
|
|
231
|
+
byte[] buffer = null;
|
|
232
|
+
int len = Serializer.JsonSerialize(
|
|
233
|
+
go,
|
|
234
|
+
SerializerEncoding.GetNormalJsonOptions(),
|
|
235
|
+
ref buffer
|
|
236
|
+
);
|
|
237
|
+
Assert.Greater(len, 0);
|
|
238
|
+
Assert.NotNull(buffer);
|
|
239
|
+
|
|
240
|
+
string json = Encoding.UTF8.GetString(buffer, 0, len);
|
|
241
|
+
using JsonDocument doc = JsonDocument.Parse(json);
|
|
242
|
+
JsonElement root = doc.RootElement;
|
|
243
|
+
Assert.AreEqual("BufferedGO", root.GetProperty("name").GetString());
|
|
244
|
+
Assert.AreEqual(expectedId, root.GetProperty("instanceId").GetInt32());
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
@@ -6,6 +6,7 @@ namespace WallstopStudios.UnityHelpers.Tests.TestUtils
|
|
|
6
6
|
using System.Threading.Tasks;
|
|
7
7
|
using NUnit.Framework;
|
|
8
8
|
using UnityEngine;
|
|
9
|
+
using UnityEngine.SceneManagement;
|
|
9
10
|
using UnityEngine.TestTools;
|
|
10
11
|
using Object = UnityEngine.Object;
|
|
11
12
|
|
|
@@ -15,6 +16,17 @@ namespace WallstopStudios.UnityHelpers.Tests.TestUtils
|
|
|
15
16
|
/// </summary>
|
|
16
17
|
public abstract class CommonTestBase
|
|
17
18
|
{
|
|
19
|
+
/// <summary>
|
|
20
|
+
/// Ensures ReflexSettings singleton is present when the Reflex package is installed so tests do not hit assertions.
|
|
21
|
+
/// </summary>
|
|
22
|
+
[SetUp]
|
|
23
|
+
public virtual void BaseSetUp()
|
|
24
|
+
{
|
|
25
|
+
#if REFLEX_PRESENT
|
|
26
|
+
ReflexTestSupport.EnsureReflexSettings();
|
|
27
|
+
#endif
|
|
28
|
+
}
|
|
29
|
+
|
|
18
30
|
// Per-test tracked UnityEngine.Objects
|
|
19
31
|
protected readonly List<Object> _trackedObjects = new();
|
|
20
32
|
|
|
@@ -72,6 +84,93 @@ namespace WallstopStudios.UnityHelpers.Tests.TestUtils
|
|
|
72
84
|
return producer;
|
|
73
85
|
}
|
|
74
86
|
|
|
87
|
+
/// <summary>
|
|
88
|
+
/// Creates a temporary scene that is automatically unloaded during teardown.
|
|
89
|
+
/// </summary>
|
|
90
|
+
/// <param name="name">Scene name.</param>
|
|
91
|
+
/// <param name="setActive">Whether to set the scene as active immediately.</param>
|
|
92
|
+
protected Scene CreateTempScene(string name, bool setActive = true)
|
|
93
|
+
{
|
|
94
|
+
Scene previousActive = SceneManager.GetActiveScene();
|
|
95
|
+
Scene scene = SceneManager.CreateScene(name);
|
|
96
|
+
|
|
97
|
+
if (setActive)
|
|
98
|
+
{
|
|
99
|
+
SceneManager.SetActiveScene(scene);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
TrackAsyncDisposal(async () =>
|
|
103
|
+
{
|
|
104
|
+
if (!scene.IsValid())
|
|
105
|
+
{
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
Scene currentActive = SceneManager.GetActiveScene();
|
|
110
|
+
if (currentActive == scene)
|
|
111
|
+
{
|
|
112
|
+
bool restored = false;
|
|
113
|
+
if (
|
|
114
|
+
previousActive.IsValid()
|
|
115
|
+
&& previousActive.isLoaded
|
|
116
|
+
&& previousActive != scene
|
|
117
|
+
)
|
|
118
|
+
{
|
|
119
|
+
SceneManager.SetActiveScene(previousActive);
|
|
120
|
+
restored = true;
|
|
121
|
+
}
|
|
122
|
+
else
|
|
123
|
+
{
|
|
124
|
+
int count = SceneManager.sceneCount;
|
|
125
|
+
for (int i = 0; i < count; i++)
|
|
126
|
+
{
|
|
127
|
+
Scene candidate = SceneManager.GetSceneAt(i);
|
|
128
|
+
if (!candidate.IsValid() || !candidate.isLoaded || candidate == scene)
|
|
129
|
+
{
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
SceneManager.SetActiveScene(candidate);
|
|
134
|
+
restored = true;
|
|
135
|
+
break;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
if (!restored)
|
|
140
|
+
{
|
|
141
|
+
Scene fallback = SceneManager.CreateScene("RuntimeTestFallbackScene");
|
|
142
|
+
SceneManager.SetActiveScene(fallback);
|
|
143
|
+
TrackAsyncDisposal(async () =>
|
|
144
|
+
{
|
|
145
|
+
AsyncOperation unloadFallback = SceneManager.UnloadSceneAsync(fallback);
|
|
146
|
+
if (unloadFallback == null)
|
|
147
|
+
{
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
while (!unloadFallback.isDone)
|
|
151
|
+
{
|
|
152
|
+
await Task.Yield();
|
|
153
|
+
}
|
|
154
|
+
return;
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
AsyncOperation unload = SceneManager.UnloadSceneAsync(scene);
|
|
160
|
+
if (unload == null)
|
|
161
|
+
{
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
while (!unload.isDone)
|
|
166
|
+
{
|
|
167
|
+
await Task.Yield();
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
return scene;
|
|
172
|
+
}
|
|
173
|
+
|
|
75
174
|
/// <summary>
|
|
76
175
|
/// NUnit teardown for non-Unity tests and EditMode cleanup.
|
|
77
176
|
/// Uses DestroyImmediate when not playing and disposes disposables.
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
#if REFLEX_PRESENT
|
|
2
|
+
namespace WallstopStudios.UnityHelpers.Tests.TestUtils
|
|
3
|
+
{
|
|
4
|
+
using System;
|
|
5
|
+
using System.Collections.Generic;
|
|
6
|
+
using System.Linq;
|
|
7
|
+
using System.Reflection;
|
|
8
|
+
using UnityEngine;
|
|
9
|
+
|
|
10
|
+
public static class ReflexTestSupport
|
|
11
|
+
{
|
|
12
|
+
private const string ReflexSettingsTypeName = "Reflex.Configuration.ReflexSettings";
|
|
13
|
+
private const string InstanceFieldName = "_instance";
|
|
14
|
+
private const string LogLevelBackingFieldName = "<LogLevel>k__BackingField";
|
|
15
|
+
private const string ProjectScopesBackingFieldName = "<ProjectScopes>k__BackingField";
|
|
16
|
+
private const string LogLevelTypeName = "Reflex.Logging.LogLevel";
|
|
17
|
+
private const string ProjectScopeTypeName = "Reflex.Core.ProjectScope";
|
|
18
|
+
|
|
19
|
+
private static bool _initialized;
|
|
20
|
+
|
|
21
|
+
public static void EnsureReflexSettings()
|
|
22
|
+
{
|
|
23
|
+
if (_initialized)
|
|
24
|
+
{
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
Type settingsType = FindType(ReflexSettingsTypeName);
|
|
29
|
+
if (settingsType == null)
|
|
30
|
+
{
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
FieldInfo instanceField = settingsType.GetField(
|
|
35
|
+
InstanceFieldName,
|
|
36
|
+
BindingFlags.NonPublic | BindingFlags.Static
|
|
37
|
+
);
|
|
38
|
+
if (instanceField == null)
|
|
39
|
+
{
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
object currentInstance = instanceField.GetValue(null);
|
|
44
|
+
if (currentInstance == null)
|
|
45
|
+
{
|
|
46
|
+
ScriptableObject settings = ScriptableObject.CreateInstance(settingsType);
|
|
47
|
+
SetInstanceField(
|
|
48
|
+
settingsType,
|
|
49
|
+
settings,
|
|
50
|
+
LogLevelBackingFieldName,
|
|
51
|
+
GetLogLevelInfo()
|
|
52
|
+
);
|
|
53
|
+
SetInstanceField(
|
|
54
|
+
settingsType,
|
|
55
|
+
settings,
|
|
56
|
+
ProjectScopesBackingFieldName,
|
|
57
|
+
CreateEmptyProjectScopesList()
|
|
58
|
+
);
|
|
59
|
+
instanceField.SetValue(null, settings);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
_initialized = true;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
private static void SetInstanceField(
|
|
66
|
+
Type declaringType,
|
|
67
|
+
object instance,
|
|
68
|
+
string fieldName,
|
|
69
|
+
object value
|
|
70
|
+
)
|
|
71
|
+
{
|
|
72
|
+
FieldInfo field = declaringType.GetField(
|
|
73
|
+
fieldName,
|
|
74
|
+
BindingFlags.Instance | BindingFlags.NonPublic
|
|
75
|
+
);
|
|
76
|
+
field?.SetValue(instance, value);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
private static object GetLogLevelInfo()
|
|
80
|
+
{
|
|
81
|
+
Type logLevelType = FindType(LogLevelTypeName);
|
|
82
|
+
if (logLevelType == null)
|
|
83
|
+
{
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return Enum.Parse(logLevelType, "Info", ignoreCase: true);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
private static object CreateEmptyProjectScopesList()
|
|
91
|
+
{
|
|
92
|
+
Type projectScopeType = FindType(ProjectScopeTypeName);
|
|
93
|
+
if (projectScopeType == null)
|
|
94
|
+
{
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
Type listType = typeof(List<>).MakeGenericType(projectScopeType);
|
|
99
|
+
return Activator.CreateInstance(listType);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
private static Type FindType(string fullName)
|
|
103
|
+
{
|
|
104
|
+
return AppDomain
|
|
105
|
+
.CurrentDomain.GetAssemblies()
|
|
106
|
+
.Select(assembly => assembly.GetType(fullName))
|
|
107
|
+
.FirstOrDefault(type => type != null);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
#endif
|
|
@@ -11,7 +11,7 @@ namespace WallstopStudios.UnityHelpers.Tests.Utils
|
|
|
11
11
|
public void RoundtripVariousSizes()
|
|
12
12
|
{
|
|
13
13
|
Random random = new(12345);
|
|
14
|
-
int[] sizes =
|
|
14
|
+
int[] sizes = { 0, 1, 3, 5, 32, 64, 257, 1024, 4096 };
|
|
15
15
|
foreach (int length in sizes)
|
|
16
16
|
{
|
|
17
17
|
byte[] data = new byte[length];
|
|
@@ -24,7 +24,7 @@ namespace WallstopStudios.UnityHelpers.Tests.Utils
|
|
|
24
24
|
[Test]
|
|
25
25
|
public void DecompressingGarbageThrows()
|
|
26
26
|
{
|
|
27
|
-
byte[] garbage =
|
|
27
|
+
byte[] garbage = { 1, 2, 3, 4, 5 };
|
|
28
28
|
Assert.Throws<Exception>(() => LZMA.Decompress(garbage));
|
|
29
29
|
}
|
|
30
30
|
}
|
|
@@ -24,12 +24,12 @@ namespace WallstopStudios.UnityHelpers.Tests.Utils
|
|
|
24
24
|
);
|
|
25
25
|
|
|
26
26
|
// Define a physics shape for the sprite (a simple rectangle)
|
|
27
|
-
Vector2[] physicsShape =
|
|
27
|
+
Vector2[] physicsShape =
|
|
28
28
|
{
|
|
29
|
-
new
|
|
30
|
-
new
|
|
31
|
-
new
|
|
32
|
-
new
|
|
29
|
+
new(-0.5f, -0.5f),
|
|
30
|
+
new(-0.5f, 0.5f),
|
|
31
|
+
new(0.5f, 0.5f),
|
|
32
|
+
new(0.5f, -0.5f),
|
|
33
33
|
};
|
|
34
34
|
_testSprite.OverridePhysicsShape(new[] { physicsShape });
|
|
35
35
|
}
|