com.wallstop-studios.unity-helpers 2.0.0 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/format-on-demand.yml +2 -2
- package/.github/workflows/markdown-json.yml +1 -1
- package/.github/workflows/npm-publish.yml +1 -1
- package/.github/workflows/prettier-autofix.yml +4 -4
- package/.github/workflows/yaml-format-lint.yml +1 -1
- package/Docs/EFFECTS_SYSTEM.md +1316 -0
- package/{EFFECTS_SYSTEM_TUTORIAL.md → Docs/EFFECTS_SYSTEM_TUTORIAL.md} +1 -1
- package/{GETTING_STARTED.md → Docs/GETTING_STARTED.md} +10 -8
- package/{GLOSSARY.md → Docs/GLOSSARY.md} +4 -4
- package/Docs/HELPER_UTILITIES.md +885 -0
- package/Docs/HELPER_UTILITIES.md.meta +7 -0
- package/{INDEX.md → Docs/INDEX.md} +107 -62
- package/Docs/MATH_AND_EXTENSIONS.md +1039 -0
- package/{RANDOM_PERFORMANCE.md → Docs/RANDOM_PERFORMANCE.md} +15 -15
- package/{RELATIONAL_COMPONENTS.md → Docs/RELATIONAL_COMPONENTS.md} +21 -3
- package/{SPATIAL_TREES_2D_GUIDE.md → Docs/SPATIAL_TREES_2D_GUIDE.md} +2 -2
- package/{SPATIAL_TREES_3D_GUIDE.md → Docs/SPATIAL_TREES_3D_GUIDE.md} +1 -1
- package/{SPATIAL_TREE_2D_PERFORMANCE.md → Docs/SPATIAL_TREE_2D_PERFORMANCE.md} +64 -64
- package/{SPATIAL_TREE_3D_PERFORMANCE.md → Docs/SPATIAL_TREE_3D_PERFORMANCE.md} +64 -64
- package/Docs/UTILITY_COMPONENTS.md +906 -0
- package/Docs/UTILITY_COMPONENTS.md.meta +7 -0
- package/Docs/VISUAL_COMPONENTS.md +337 -0
- package/Docs/VISUAL_COMPONENTS.md.meta +7 -0
- package/Editor/Sprites/AnimationCopier.cs +3 -3
- package/README.md +69 -62
- package/Runtime/AssemblyInfo.cs +2 -0
- package/Runtime/Core/DataStructure/KDTree3D.cs +1 -1
- package/Runtime/Core/DataStructure/OctTree3D.cs +1 -1
- package/Runtime/Core/Extension/AsyncOperationExtensions.cs +122 -0
- package/Runtime/Core/Helper/Logging/UnityLogTagFormatter.cs +76 -90
- package/Runtime/Core/Serialization/ProtobufUnitySurrogates.cs +24 -29
- package/Runtime/Integrations/Reflex/AssemblyInfo.cs +7 -0
- package/Runtime/Integrations/Reflex/AssemblyInfo.cs.meta +11 -0
- package/Runtime/Integrations/Reflex/ContainerRelationalExtensions.cs +198 -0
- package/Runtime/Integrations/Reflex/ContainerRelationalExtensions.cs.meta +11 -0
- package/Runtime/Integrations/Reflex/RelationalComponentsInstaller.cs +86 -0
- package/Runtime/Integrations/Reflex/RelationalComponentsInstaller.cs.meta +11 -0
- package/Runtime/Integrations/Reflex/RelationalReflexSceneBootstrapper.cs +316 -0
- package/Runtime/Integrations/Reflex/RelationalReflexSceneBootstrapper.cs.meta +11 -0
- package/Runtime/Integrations/Reflex/RelationalSceneAssignmentOptions.cs +86 -0
- package/Runtime/Integrations/Reflex/RelationalSceneAssignmentOptions.cs.meta +11 -0
- package/Runtime/Integrations/Reflex/WallstopStudios.UnityHelpers.Integration.Reflex.asmdef +20 -0
- package/Runtime/Integrations/Reflex/WallstopStudios.UnityHelpers.Integration.Reflex.asmdef.meta +7 -0
- package/Runtime/Integrations/Reflex.meta +8 -0
- package/Runtime/Utils/ScriptableObjectSingleton.cs +1 -1
- package/Samples~/DI - Reflex/README.md +527 -0
- package/Samples~/DI - Reflex/README.md.meta +7 -0
- package/Samples~/DI - Reflex/Scripts/ReflexPaletteService.cs +36 -0
- package/Samples~/DI - Reflex/Scripts/ReflexPaletteService.cs.meta +11 -0
- package/Samples~/DI - Reflex/Scripts/ReflexRelationalConsumer.cs +79 -0
- package/Samples~/DI - Reflex/Scripts/ReflexRelationalConsumer.cs.meta +11 -0
- package/Samples~/DI - Reflex/Scripts/ReflexSampleInstaller.cs +30 -0
- package/Samples~/DI - Reflex/Scripts/ReflexSampleInstaller.cs.meta +11 -0
- package/Samples~/DI - Reflex/Scripts/ReflexSpawner.cs +79 -0
- package/Samples~/DI - Reflex/Scripts/ReflexSpawner.cs.meta +11 -0
- package/Samples~/DI - Reflex/Scripts/Samples.UnityHelpers.DI.Reflex.asmdef +26 -0
- package/Samples~/DI - Reflex/Scripts/Samples.UnityHelpers.DI.Reflex.asmdef.meta +9 -0
- package/Samples~/DI - Reflex/Scripts.meta +8 -0
- package/Samples~/DI - Reflex.meta +8 -0
- package/Samples~/DI - VContainer/README.md +6 -5
- package/Samples~/DI - Zenject/README.md +6 -5
- package/Tests/Editor/Core/Attributes/RelationalComponentAssignerTests.cs +29 -31
- package/Tests/Editor/Integrations/Reflex/ReflexIntegrationCompilationTests.cs +41 -0
- package/Tests/Editor/Integrations/Reflex/ReflexIntegrationCompilationTests.cs.meta +11 -0
- package/Tests/Editor/Integrations/Reflex/WallstopStudios.UnityHelpers.Tests.Editor.Reflex.asmdef +27 -0
- package/Tests/Editor/Integrations/Reflex/WallstopStudios.UnityHelpers.Tests.Editor.Reflex.asmdef.meta +7 -0
- package/Tests/Editor/Integrations/Reflex.meta +8 -0
- package/Tests/Editor/Integrations/VContainer/VContainerRelationalEntryPointTests.cs +15 -16
- package/Tests/Editor/Integrations/VContainer/VContainerRelationalHelpersTests.cs +7 -13
- package/Tests/Editor/Integrations/Zenject/ZenjectRelationalHelpersTests.cs +7 -11
- package/Tests/Editor/Integrations/Zenject/ZenjectRelationalInitializerTests.cs +19 -21
- package/Tests/Editor/PersistentDirectorySettingsTests.cs +0 -1
- package/Tests/Editor/Sprites/AnimationCopierFilterTests.cs +0 -1
- package/Tests/Editor/Sprites/AnimationViewerWindowTests.cs +2 -2
- package/Tests/Editor/Tools/ImageBlurToolTests.cs +1 -1
- package/Tests/Editor/Utils/CommonTestBase.cs +17 -0
- package/Tests/Editor/Utils/ScriptableObjectSingletonCreatorTests.cs +1 -1
- package/Tests/Runtime/Extensions/AsyncOperationExtensionsTests.cs +179 -0
- package/Tests/Runtime/Extensions/RandomExtensionTests.cs +55 -0
- package/Tests/Runtime/Extensions/UnityLogTagFormatterEdgeTests.cs +84 -0
- package/Tests/Runtime/Integrations/Reflex/RelationalComponentsReflexTests.cs +445 -0
- package/Tests/Runtime/Integrations/Reflex/RelationalComponentsReflexTests.cs.meta +11 -0
- package/Tests/Runtime/Integrations/Reflex/WallstopStudios.UnityHelpers.Tests.Runtime.Reflex.asmdef +28 -0
- package/Tests/Runtime/Integrations/Reflex/WallstopStudios.UnityHelpers.Tests.Runtime.Reflex.asmdef.meta +7 -0
- package/Tests/Runtime/Integrations/Reflex.meta +8 -0
- package/Tests/Runtime/Integrations/VContainer/RelationalComponentsVContainerTests.cs +24 -29
- package/Tests/Runtime/Integrations/VContainer/RelationalObjectPoolsVContainerTests.cs +8 -3
- package/Tests/Runtime/Integrations/Zenject/RelationalComponentsZenjectTests.cs +10 -20
- package/Tests/Runtime/Performance/RandomPerformanceTests.cs +1 -1
- package/Tests/Runtime/Performance/SpatialTree2DPerformanceTests.cs +1 -1
- package/Tests/Runtime/Performance/SpatialTree3DPerformanceTests.cs +1 -1
- package/Tests/Runtime/Serialization/JsonRoundtripComprehensiveTests.cs +4 -9
- package/Tests/Runtime/Serialization/ProtoRoundtripComprehensiveTests.cs +13 -13
- package/Tests/Runtime/TestUtils/CommonTestBase.cs +11 -0
- package/Tests/Runtime/TestUtils/ReflexTestSupport.cs +111 -0
- package/Tests/Runtime/TestUtils/ReflexTestSupport.cs.meta +12 -0
- package/Tests/Runtime/Utils/MatchColliderToSpriteTests.cs +4 -4
- package/Tests/TestUtils.meta +8 -0
- package/package.json +6 -1
- package/EFFECTS_SYSTEM.md +0 -242
- package/MATH_AND_EXTENSIONS.md +0 -316
- /package/{CHANGELOG.md → Docs/CHANGELOG.md} +0 -0
- /package/{CHANGELOG.md.meta → Docs/CHANGELOG.md.meta} +0 -0
- /package/{CONTRIBUTING.md → Docs/CONTRIBUTING.md} +0 -0
- /package/{CONTRIBUTING.md.meta → Docs/CONTRIBUTING.md.meta} +0 -0
- /package/{DATA_STRUCTURES.md → Docs/DATA_STRUCTURES.md} +0 -0
- /package/{DATA_STRUCTURES.md.meta → Docs/DATA_STRUCTURES.md.meta} +0 -0
- /package/{EDITOR_TOOLS_GUIDE.md → Docs/EDITOR_TOOLS_GUIDE.md} +0 -0
- /package/{EDITOR_TOOLS_GUIDE.md.meta → Docs/EDITOR_TOOLS_GUIDE.md.meta} +0 -0
- /package/{EFFECTS_SYSTEM.md.meta → Docs/EFFECTS_SYSTEM.md.meta} +0 -0
- /package/{EFFECTS_SYSTEM_TUTORIAL.md.meta → Docs/EFFECTS_SYSTEM_TUTORIAL.md.meta} +0 -0
- /package/{GETTING_STARTED.md.meta → Docs/GETTING_STARTED.md.meta} +0 -0
- /package/{GLOSSARY.md.meta → Docs/GLOSSARY.md.meta} +0 -0
- /package/{HULLS.md → Docs/HULLS.md} +0 -0
- /package/{HULLS.md.meta → Docs/HULLS.md.meta} +0 -0
- /package/{INDEX.md.meta → Docs/INDEX.md.meta} +0 -0
- /package/{LICENSE.md → Docs/LICENSE.md} +0 -0
- /package/{LICENSE.md.meta → Docs/LICENSE.md.meta} +0 -0
- /package/{MATH_AND_EXTENSIONS.md.meta → Docs/MATH_AND_EXTENSIONS.md.meta} +0 -0
- /package/{RANDOM_PERFORMANCE.md.meta → Docs/RANDOM_PERFORMANCE.md.meta} +0 -0
- /package/{REFLECTION_HELPERS.md → Docs/REFLECTION_HELPERS.md} +0 -0
- /package/{REFLECTION_HELPERS.md.meta → Docs/REFLECTION_HELPERS.md.meta} +0 -0
- /package/{RELATIONAL_COMPONENTS.md.meta → Docs/RELATIONAL_COMPONENTS.md.meta} +0 -0
- /package/{SERIALIZATION.md → Docs/SERIALIZATION.md} +0 -0
- /package/{SERIALIZATION.md.meta → Docs/SERIALIZATION.md.meta} +0 -0
- /package/{SINGLETONS.md → Docs/SINGLETONS.md} +0 -0
- /package/{SINGLETONS.md.meta → Docs/SINGLETONS.md.meta} +0 -0
- /package/{SPATIAL_TREES_2D_GUIDE.md.meta → Docs/SPATIAL_TREES_2D_GUIDE.md.meta} +0 -0
- /package/{SPATIAL_TREES_3D_GUIDE.md.meta → Docs/SPATIAL_TREES_3D_GUIDE.md.meta} +0 -0
- /package/{SPATIAL_TREE_2D_PERFORMANCE.md.meta → Docs/SPATIAL_TREE_2D_PERFORMANCE.md.meta} +0 -0
- /package/{SPATIAL_TREE_3D_PERFORMANCE.md.meta → Docs/SPATIAL_TREE_3D_PERFORMANCE.md.meta} +0 -0
- /package/{SPATIAL_TREE_SEMANTICS.md → Docs/SPATIAL_TREE_SEMANTICS.md} +0 -0
- /package/{SPATIAL_TREE_SEMANTICS.md.meta → Docs/SPATIAL_TREE_SEMANTICS.md.meta} +0 -0
- /package/{THIRD_PARTY_NOTICES.md → Docs/THIRD_PARTY_NOTICES.md} +0 -0
- /package/{THIRD_PARTY_NOTICES.md.meta → Docs/THIRD_PARTY_NOTICES.md.meta} +0 -0
|
@@ -60,6 +60,9 @@ namespace WallstopStudios.UnityHelpers.Core.Helper.Logging
|
|
|
60
60
|
Func<string, object, string> formatter
|
|
61
61
|
)>
|
|
62
62
|
> _matchingDecorations = new();
|
|
63
|
+
private readonly Dictionary<string, (int priority, int index)> _decorationLookup = new(
|
|
64
|
+
StringComparer.OrdinalIgnoreCase
|
|
65
|
+
);
|
|
63
66
|
private readonly StringBuilder _cachedStringBuilder = new();
|
|
64
67
|
private readonly List<string> _cachedDecorators = new();
|
|
65
68
|
private readonly HashSet<string> _appliedTags = new(StringComparer.OrdinalIgnoreCase);
|
|
@@ -379,89 +382,50 @@ namespace WallstopStudios.UnityHelpers.Core.Helper.Logging
|
|
|
379
382
|
bool force = false
|
|
380
383
|
)
|
|
381
384
|
{
|
|
382
|
-
|
|
383
|
-
foreach (
|
|
384
|
-
KeyValuePair<
|
|
385
|
-
int,
|
|
386
|
-
List<(
|
|
387
|
-
string tag,
|
|
388
|
-
bool editorOnly,
|
|
389
|
-
Func<string, bool> predicate,
|
|
390
|
-
Func<string, object, string> formatter
|
|
391
|
-
)>
|
|
392
|
-
> entry in _matchingDecorations
|
|
393
|
-
)
|
|
385
|
+
if (_decorationLookup.TryGetValue(tag, out (int priority, int index) existing))
|
|
394
386
|
{
|
|
395
|
-
|
|
387
|
+
if (!force)
|
|
388
|
+
{
|
|
389
|
+
return false;
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
if (existing.priority == priority)
|
|
396
393
|
{
|
|
397
|
-
(
|
|
394
|
+
List<(
|
|
398
395
|
string tag,
|
|
399
396
|
bool editorOnly,
|
|
400
397
|
Func<string, bool> predicate,
|
|
401
398
|
Func<string, object, string> formatter
|
|
402
|
-
)
|
|
403
|
-
if (
|
|
404
|
-
!string.Equals(
|
|
405
|
-
existingDecoration.tag,
|
|
406
|
-
tag,
|
|
407
|
-
StringComparison.OrdinalIgnoreCase
|
|
408
|
-
)
|
|
409
|
-
)
|
|
410
|
-
{
|
|
411
|
-
continue;
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
if (force)
|
|
415
|
-
{
|
|
416
|
-
if (priority != entry.Key)
|
|
417
|
-
{
|
|
418
|
-
entry.Value.RemoveAt(i);
|
|
419
|
-
if (entry.Value.Count == 0)
|
|
420
|
-
{
|
|
421
|
-
_matchingDecorations.Remove(entry.Key);
|
|
422
|
-
}
|
|
423
|
-
|
|
424
|
-
stopLooping = true;
|
|
425
|
-
break;
|
|
426
|
-
}
|
|
399
|
+
)> decorationsAtPriority = _matchingDecorations[priority];
|
|
427
400
|
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
return false;
|
|
401
|
+
decorationsAtPriority[existing.index] = (tag, editorOnly, predicate, format);
|
|
402
|
+
_decorationLookup[tag] = (priority, existing.index);
|
|
403
|
+
return true;
|
|
432
404
|
}
|
|
433
405
|
|
|
434
|
-
|
|
435
|
-
{
|
|
436
|
-
break;
|
|
437
|
-
}
|
|
406
|
+
RemoveDecorationInternal(existing.priority, existing.index);
|
|
438
407
|
}
|
|
439
408
|
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
Func<string, object, string> formatter
|
|
448
|
-
)> matchingDecorations
|
|
449
|
-
)
|
|
450
|
-
)
|
|
409
|
+
List<(
|
|
410
|
+
string tag,
|
|
411
|
+
bool editorOnly,
|
|
412
|
+
Func<string, bool> predicate,
|
|
413
|
+
Func<string, object, string> formatter
|
|
414
|
+
)> matchingDecorations;
|
|
415
|
+
if (!_matchingDecorations.TryGetValue(priority, out matchingDecorations))
|
|
451
416
|
{
|
|
452
|
-
|
|
417
|
+
matchingDecorations = new List<(
|
|
453
418
|
string tag,
|
|
454
419
|
bool editorOnly,
|
|
455
420
|
Func<string, bool> predicate,
|
|
456
421
|
Func<string, object, string> formatter
|
|
457
|
-
)>
|
|
458
|
-
|
|
459
|
-
(tag, editorOnly, predicate, format),
|
|
460
|
-
};
|
|
461
|
-
return true;
|
|
422
|
+
)>(1);
|
|
423
|
+
_matchingDecorations[priority] = matchingDecorations;
|
|
462
424
|
}
|
|
463
425
|
|
|
426
|
+
int indexToInsert = matchingDecorations.Count;
|
|
464
427
|
matchingDecorations.Add((tag, editorOnly, predicate, format));
|
|
428
|
+
_decorationLookup[tag] = (priority, indexToInsert);
|
|
465
429
|
return true;
|
|
466
430
|
}
|
|
467
431
|
|
|
@@ -481,35 +445,57 @@ namespace WallstopStudios.UnityHelpers.Core.Helper.Logging
|
|
|
481
445
|
) decoration
|
|
482
446
|
)
|
|
483
447
|
{
|
|
484
|
-
|
|
485
|
-
KeyValuePair<
|
|
486
|
-
int,
|
|
487
|
-
List<(
|
|
488
|
-
string tag,
|
|
489
|
-
bool editorOnly,
|
|
490
|
-
Func<string, bool> predicate,
|
|
491
|
-
Func<string, object, string> formatter
|
|
492
|
-
)>
|
|
493
|
-
> entry in _matchingDecorations
|
|
494
|
-
)
|
|
448
|
+
if (!_decorationLookup.TryGetValue(tag, out (int priority, int index) existing))
|
|
495
449
|
{
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
450
|
+
decoration = default;
|
|
451
|
+
return false;
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
decoration = RemoveDecorationInternal(existing.priority, existing.index);
|
|
455
|
+
return true;
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
private (
|
|
459
|
+
string tag,
|
|
460
|
+
bool editorOnly,
|
|
461
|
+
Func<string, bool> predicate,
|
|
462
|
+
Func<string, object, string> formatter
|
|
463
|
+
) RemoveDecorationInternal(int priority, int index)
|
|
464
|
+
{
|
|
465
|
+
List<(
|
|
466
|
+
string tag,
|
|
467
|
+
bool editorOnly,
|
|
468
|
+
Func<string, bool> predicate,
|
|
469
|
+
Func<string, object, string> formatter
|
|
470
|
+
)> decorationsAtPriority = _matchingDecorations[priority];
|
|
471
|
+
|
|
472
|
+
(
|
|
473
|
+
string tag,
|
|
474
|
+
bool editorOnly,
|
|
475
|
+
Func<string, bool> predicate,
|
|
476
|
+
Func<string, object, string> formatter
|
|
477
|
+
) removed = decorationsAtPriority[index];
|
|
478
|
+
|
|
479
|
+
decorationsAtPriority.RemoveAt(index);
|
|
480
|
+
_decorationLookup.Remove(removed.tag);
|
|
481
|
+
|
|
482
|
+
for (int i = index; i < decorationsAtPriority.Count; ++i)
|
|
483
|
+
{
|
|
484
|
+
(
|
|
485
|
+
string tag,
|
|
486
|
+
bool editorOnly,
|
|
487
|
+
Func<string, bool> predicate,
|
|
488
|
+
Func<string, object, string> formatter
|
|
489
|
+
) entry = decorationsAtPriority[i];
|
|
490
|
+
_decorationLookup[entry.tag] = (priority, i);
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
if (decorationsAtPriority.Count == 0)
|
|
494
|
+
{
|
|
495
|
+
_matchingDecorations.Remove(priority);
|
|
509
496
|
}
|
|
510
497
|
|
|
511
|
-
|
|
512
|
-
return false;
|
|
498
|
+
return removed;
|
|
513
499
|
}
|
|
514
500
|
|
|
515
501
|
[HideInCallstack]
|
|
@@ -15,10 +15,9 @@ namespace WallstopStudios.UnityHelpers.Core.Serialization
|
|
|
15
15
|
[ProtoMember(2)]
|
|
16
16
|
public float y;
|
|
17
17
|
|
|
18
|
-
public static implicit operator Vector2Surrogate(Vector2 v) =>
|
|
19
|
-
new Vector2Surrogate { x = v.x, y = v.y };
|
|
18
|
+
public static implicit operator Vector2Surrogate(Vector2 v) => new() { x = v.x, y = v.y };
|
|
20
19
|
|
|
21
|
-
public static implicit operator Vector2(Vector2Surrogate s) => new
|
|
20
|
+
public static implicit operator Vector2(Vector2Surrogate s) => new(s.x, s.y);
|
|
22
21
|
}
|
|
23
22
|
|
|
24
23
|
[ProtoContract]
|
|
@@ -34,14 +33,14 @@ namespace WallstopStudios.UnityHelpers.Core.Serialization
|
|
|
34
33
|
public float z;
|
|
35
34
|
|
|
36
35
|
public static implicit operator Vector3Surrogate(Vector3 v) =>
|
|
37
|
-
new
|
|
36
|
+
new()
|
|
38
37
|
{
|
|
39
38
|
x = v.x,
|
|
40
39
|
y = v.y,
|
|
41
40
|
z = v.z,
|
|
42
41
|
};
|
|
43
42
|
|
|
44
|
-
public static implicit operator Vector3(Vector3Surrogate s) => new
|
|
43
|
+
public static implicit operator Vector3(Vector3Surrogate s) => new(s.x, s.y, s.z);
|
|
45
44
|
}
|
|
46
45
|
|
|
47
46
|
[ProtoContract]
|
|
@@ -60,7 +59,7 @@ namespace WallstopStudios.UnityHelpers.Core.Serialization
|
|
|
60
59
|
public float w;
|
|
61
60
|
|
|
62
61
|
public static implicit operator QuaternionSurrogate(Quaternion q) =>
|
|
63
|
-
new
|
|
62
|
+
new()
|
|
64
63
|
{
|
|
65
64
|
x = q.x,
|
|
66
65
|
y = q.y,
|
|
@@ -69,7 +68,7 @@ namespace WallstopStudios.UnityHelpers.Core.Serialization
|
|
|
69
68
|
};
|
|
70
69
|
|
|
71
70
|
public static implicit operator Quaternion(QuaternionSurrogate s) =>
|
|
72
|
-
new
|
|
71
|
+
new(s.x, s.y, s.z, s.w);
|
|
73
72
|
}
|
|
74
73
|
|
|
75
74
|
[ProtoContract]
|
|
@@ -88,7 +87,7 @@ namespace WallstopStudios.UnityHelpers.Core.Serialization
|
|
|
88
87
|
public float a;
|
|
89
88
|
|
|
90
89
|
public static implicit operator ColorSurrogate(Color c) =>
|
|
91
|
-
new
|
|
90
|
+
new()
|
|
92
91
|
{
|
|
93
92
|
r = c.r,
|
|
94
93
|
g = c.g,
|
|
@@ -96,7 +95,7 @@ namespace WallstopStudios.UnityHelpers.Core.Serialization
|
|
|
96
95
|
a = c.a,
|
|
97
96
|
};
|
|
98
97
|
|
|
99
|
-
public static implicit operator Color(ColorSurrogate s) => new
|
|
98
|
+
public static implicit operator Color(ColorSurrogate s) => new(s.r, s.g, s.b, s.a);
|
|
100
99
|
}
|
|
101
100
|
|
|
102
101
|
[ProtoContract]
|
|
@@ -115,7 +114,7 @@ namespace WallstopStudios.UnityHelpers.Core.Serialization
|
|
|
115
114
|
public byte a;
|
|
116
115
|
|
|
117
116
|
public static implicit operator Color32Surrogate(Color32 c) =>
|
|
118
|
-
new
|
|
117
|
+
new()
|
|
119
118
|
{
|
|
120
119
|
r = c.r,
|
|
121
120
|
g = c.g,
|
|
@@ -123,8 +122,7 @@ namespace WallstopStudios.UnityHelpers.Core.Serialization
|
|
|
123
122
|
a = c.a,
|
|
124
123
|
};
|
|
125
124
|
|
|
126
|
-
public static implicit operator Color32(Color32Surrogate s) =>
|
|
127
|
-
new Color32(s.r, s.g, s.b, s.a);
|
|
125
|
+
public static implicit operator Color32(Color32Surrogate s) => new(s.r, s.g, s.b, s.a);
|
|
128
126
|
}
|
|
129
127
|
|
|
130
128
|
[ProtoContract]
|
|
@@ -143,7 +141,7 @@ namespace WallstopStudios.UnityHelpers.Core.Serialization
|
|
|
143
141
|
public float height;
|
|
144
142
|
|
|
145
143
|
public static implicit operator RectSurrogate(Rect r) =>
|
|
146
|
-
new
|
|
144
|
+
new()
|
|
147
145
|
{
|
|
148
146
|
x = r.x,
|
|
149
147
|
y = r.y,
|
|
@@ -151,8 +149,7 @@ namespace WallstopStudios.UnityHelpers.Core.Serialization
|
|
|
151
149
|
height = r.height,
|
|
152
150
|
};
|
|
153
151
|
|
|
154
|
-
public static implicit operator Rect(RectSurrogate s) =>
|
|
155
|
-
new Rect(s.x, s.y, s.width, s.height);
|
|
152
|
+
public static implicit operator Rect(RectSurrogate s) => new(s.x, s.y, s.width, s.height);
|
|
156
153
|
}
|
|
157
154
|
|
|
158
155
|
[ProtoContract]
|
|
@@ -171,7 +168,7 @@ namespace WallstopStudios.UnityHelpers.Core.Serialization
|
|
|
171
168
|
public int height;
|
|
172
169
|
|
|
173
170
|
public static implicit operator RectIntSurrogate(RectInt r) =>
|
|
174
|
-
new
|
|
171
|
+
new()
|
|
175
172
|
{
|
|
176
173
|
x = r.x,
|
|
177
174
|
y = r.y,
|
|
@@ -180,7 +177,7 @@ namespace WallstopStudios.UnityHelpers.Core.Serialization
|
|
|
180
177
|
};
|
|
181
178
|
|
|
182
179
|
public static implicit operator RectInt(RectIntSurrogate s) =>
|
|
183
|
-
new
|
|
180
|
+
new(s.x, s.y, s.width, s.height);
|
|
184
181
|
}
|
|
185
182
|
|
|
186
183
|
[ProtoContract]
|
|
@@ -205,7 +202,7 @@ namespace WallstopStudios.UnityHelpers.Core.Serialization
|
|
|
205
202
|
public float sz;
|
|
206
203
|
|
|
207
204
|
public static implicit operator BoundsSurrogate(Bounds b) =>
|
|
208
|
-
new
|
|
205
|
+
new()
|
|
209
206
|
{
|
|
210
207
|
cx = b.center.x,
|
|
211
208
|
cy = b.center.y,
|
|
@@ -216,7 +213,7 @@ namespace WallstopStudios.UnityHelpers.Core.Serialization
|
|
|
216
213
|
};
|
|
217
214
|
|
|
218
215
|
public static implicit operator Bounds(BoundsSurrogate s) =>
|
|
219
|
-
new
|
|
216
|
+
new(new Vector3(s.cx, s.cy, s.cz), new Vector3(s.sx, s.sy, s.sz));
|
|
220
217
|
}
|
|
221
218
|
|
|
222
219
|
[ProtoContract]
|
|
@@ -241,7 +238,7 @@ namespace WallstopStudios.UnityHelpers.Core.Serialization
|
|
|
241
238
|
public int sz;
|
|
242
239
|
|
|
243
240
|
public static implicit operator BoundsIntSurrogate(BoundsInt b) =>
|
|
244
|
-
new
|
|
241
|
+
new()
|
|
245
242
|
{
|
|
246
243
|
px = b.position.x,
|
|
247
244
|
py = b.position.y,
|
|
@@ -252,7 +249,7 @@ namespace WallstopStudios.UnityHelpers.Core.Serialization
|
|
|
252
249
|
};
|
|
253
250
|
|
|
254
251
|
public static implicit operator BoundsInt(BoundsIntSurrogate s) =>
|
|
255
|
-
new
|
|
252
|
+
new(new Vector3Int(s.px, s.py, s.pz), new Vector3Int(s.sx, s.sy, s.sz));
|
|
256
253
|
}
|
|
257
254
|
|
|
258
255
|
[ProtoContract]
|
|
@@ -265,10 +262,9 @@ namespace WallstopStudios.UnityHelpers.Core.Serialization
|
|
|
265
262
|
public int y;
|
|
266
263
|
|
|
267
264
|
public static implicit operator Vector2IntSurrogate(Vector2Int v) =>
|
|
268
|
-
new
|
|
265
|
+
new() { x = v.x, y = v.y };
|
|
269
266
|
|
|
270
|
-
public static implicit operator Vector2Int(Vector2IntSurrogate s) =>
|
|
271
|
-
new Vector2Int(s.x, s.y);
|
|
267
|
+
public static implicit operator Vector2Int(Vector2IntSurrogate s) => new(s.x, s.y);
|
|
272
268
|
}
|
|
273
269
|
|
|
274
270
|
[ProtoContract]
|
|
@@ -284,15 +280,14 @@ namespace WallstopStudios.UnityHelpers.Core.Serialization
|
|
|
284
280
|
public int z;
|
|
285
281
|
|
|
286
282
|
public static implicit operator Vector3IntSurrogate(Vector3Int v) =>
|
|
287
|
-
new
|
|
283
|
+
new()
|
|
288
284
|
{
|
|
289
285
|
x = v.x,
|
|
290
286
|
y = v.y,
|
|
291
287
|
z = v.z,
|
|
292
288
|
};
|
|
293
289
|
|
|
294
|
-
public static implicit operator Vector3Int(Vector3IntSurrogate s) =>
|
|
295
|
-
new Vector3Int(s.x, s.y, s.z);
|
|
290
|
+
public static implicit operator Vector3Int(Vector3IntSurrogate s) => new(s.x, s.y, s.z);
|
|
296
291
|
}
|
|
297
292
|
|
|
298
293
|
[ProtoContract]
|
|
@@ -309,7 +304,7 @@ namespace WallstopStudios.UnityHelpers.Core.Serialization
|
|
|
309
304
|
|
|
310
305
|
[Obsolete("Obsolete")]
|
|
311
306
|
public static implicit operator ResolutionSurrogate(Resolution r) =>
|
|
312
|
-
new
|
|
307
|
+
new()
|
|
313
308
|
{
|
|
314
309
|
width = r.width,
|
|
315
310
|
height = r.height,
|
|
@@ -318,7 +313,7 @@ namespace WallstopStudios.UnityHelpers.Core.Serialization
|
|
|
318
313
|
|
|
319
314
|
public static implicit operator Resolution(ResolutionSurrogate s)
|
|
320
315
|
{
|
|
321
|
-
Resolution r = new
|
|
316
|
+
Resolution r = new() { width = s.width, height = s.height };
|
|
322
317
|
#if !UNITY_2022_2_OR_NEWER
|
|
323
318
|
r.refreshRate = s.refreshRate;
|
|
324
319
|
#endif
|
|
@@ -0,0 +1,7 @@
|
|
|
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.Reflex")]
|
|
7
|
+
[assembly: InternalsVisibleTo("WallstopStudios.UnityHelpers.Tests.Editor.Reflex")]
|
|
@@ -0,0 +1,198 @@
|
|
|
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 global::Reflex.Injectors;
|
|
8
|
+
using UnityEngine;
|
|
9
|
+
using WallstopStudios.UnityHelpers.Core.Attributes;
|
|
10
|
+
using WallstopStudios.UnityHelpers.Utils;
|
|
11
|
+
|
|
12
|
+
/// <summary>
|
|
13
|
+
/// Extension methods that bridge Reflex containers with relational component assignment.
|
|
14
|
+
/// </summary>
|
|
15
|
+
public static class ContainerRelationalExtensions
|
|
16
|
+
{
|
|
17
|
+
/// <summary>
|
|
18
|
+
/// Injects a component using Reflex and assigns its relational fields.
|
|
19
|
+
/// </summary>
|
|
20
|
+
/// <typeparam name="T">Component type.</typeparam>
|
|
21
|
+
/// <param name="container">Reflex container.</param>
|
|
22
|
+
/// <param name="component">Component instance to inject and hydrate.</param>
|
|
23
|
+
/// <returns>The injected component instance.</returns>
|
|
24
|
+
public static T InjectWithRelations<T>(this Container container, T component)
|
|
25
|
+
where T : Component
|
|
26
|
+
{
|
|
27
|
+
if (component == null)
|
|
28
|
+
{
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (container != null)
|
|
33
|
+
{
|
|
34
|
+
AttributeInjector.Inject(component, container);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
container.AssignRelationalComponents(component);
|
|
38
|
+
return component;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/// <summary>
|
|
42
|
+
/// Assigns relational component fields on the supplied component.
|
|
43
|
+
/// </summary>
|
|
44
|
+
/// <param name="container">Reflex container.</param>
|
|
45
|
+
/// <param name="component">Component to hydrate.</param>
|
|
46
|
+
public static void AssignRelationalComponents(this Container container, Component component)
|
|
47
|
+
{
|
|
48
|
+
if (component == null)
|
|
49
|
+
{
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
IRelationalComponentAssigner assigner = ResolveAssigner(container);
|
|
54
|
+
if (assigner != null)
|
|
55
|
+
{
|
|
56
|
+
assigner.Assign(component);
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
component.AssignRelationalComponents();
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/// <summary>
|
|
64
|
+
/// Assigns relational component fields across a GameObject hierarchy.
|
|
65
|
+
/// </summary>
|
|
66
|
+
/// <param name="container">Reflex container.</param>
|
|
67
|
+
/// <param name="root">Hierarchy root.</param>
|
|
68
|
+
/// <param name="includeInactiveChildren">
|
|
69
|
+
/// When true, includes inactive children during assignment.
|
|
70
|
+
/// </param>
|
|
71
|
+
public static void AssignRelationalHierarchy(
|
|
72
|
+
this Container container,
|
|
73
|
+
GameObject root,
|
|
74
|
+
bool includeInactiveChildren = true
|
|
75
|
+
)
|
|
76
|
+
{
|
|
77
|
+
if (root == null)
|
|
78
|
+
{
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
IRelationalComponentAssigner assigner = ResolveAssigner(container);
|
|
83
|
+
if (assigner != null)
|
|
84
|
+
{
|
|
85
|
+
assigner.AssignHierarchy(root, includeInactiveChildren);
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
using PooledResource<List<Component>> pooledComponents = Buffers<Component>.List.Get(
|
|
90
|
+
out List<Component> components
|
|
91
|
+
);
|
|
92
|
+
root.GetComponentsInChildren(includeInactiveChildren, components);
|
|
93
|
+
for (int i = 0; i < components.Count; i++)
|
|
94
|
+
{
|
|
95
|
+
Component component = components[i];
|
|
96
|
+
if (component == null)
|
|
97
|
+
{
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
component.AssignRelationalComponents();
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/// <summary>
|
|
105
|
+
/// Instantiates a component prefab, injects it, and assigns relational fields.
|
|
106
|
+
/// </summary>
|
|
107
|
+
/// <typeparam name="T">Component type contained by the prefab.</typeparam>
|
|
108
|
+
/// <param name="container">Reflex container.</param>
|
|
109
|
+
/// <param name="prefab">Component prefab.</param>
|
|
110
|
+
/// <param name="parent">Optional parent transform.</param>
|
|
111
|
+
/// <returns>The instantiated and hydrated component.</returns>
|
|
112
|
+
public static T InstantiateComponentWithRelations<T>(
|
|
113
|
+
this Container container,
|
|
114
|
+
T prefab,
|
|
115
|
+
Transform parent = null
|
|
116
|
+
)
|
|
117
|
+
where T : Component
|
|
118
|
+
{
|
|
119
|
+
if (prefab == null)
|
|
120
|
+
{
|
|
121
|
+
throw new ArgumentNullException(nameof(prefab));
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
T instance = UnityEngine.Object.Instantiate(prefab, parent);
|
|
125
|
+
return container.InjectWithRelations(instance);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/// <summary>
|
|
129
|
+
/// Instantiates a GameObject prefab, injects the hierarchy, and assigns relational fields.
|
|
130
|
+
/// </summary>
|
|
131
|
+
/// <param name="container">Reflex container.</param>
|
|
132
|
+
/// <param name="prefab">GameObject prefab.</param>
|
|
133
|
+
/// <param name="parent">Optional parent transform.</param>
|
|
134
|
+
/// <param name="includeInactiveChildren">
|
|
135
|
+
/// When true, includes inactive children during relational assignment.
|
|
136
|
+
/// </param>
|
|
137
|
+
/// <returns>The instantiated GameObject.</returns>
|
|
138
|
+
public static GameObject InstantiateGameObjectWithRelations(
|
|
139
|
+
this Container container,
|
|
140
|
+
GameObject prefab,
|
|
141
|
+
Transform parent = null,
|
|
142
|
+
bool includeInactiveChildren = true
|
|
143
|
+
)
|
|
144
|
+
{
|
|
145
|
+
if (prefab == null)
|
|
146
|
+
{
|
|
147
|
+
throw new ArgumentNullException(nameof(prefab));
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
GameObject instance = UnityEngine.Object.Instantiate(prefab, parent);
|
|
151
|
+
container.InjectGameObjectWithRelations(instance, includeInactiveChildren);
|
|
152
|
+
return instance;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/// <summary>
|
|
156
|
+
/// Injects all components in a hierarchy and assigns relational fields.
|
|
157
|
+
/// </summary>
|
|
158
|
+
/// <param name="container">Reflex container.</param>
|
|
159
|
+
/// <param name="root">Root GameObject.</param>
|
|
160
|
+
/// <param name="includeInactiveChildren">
|
|
161
|
+
/// When true, includes inactive children during relational assignment.
|
|
162
|
+
/// </param>
|
|
163
|
+
public static void InjectGameObjectWithRelations(
|
|
164
|
+
this Container container,
|
|
165
|
+
GameObject root,
|
|
166
|
+
bool includeInactiveChildren = true
|
|
167
|
+
)
|
|
168
|
+
{
|
|
169
|
+
if (root == null)
|
|
170
|
+
{
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
if (container != null)
|
|
175
|
+
{
|
|
176
|
+
GameObjectInjector.InjectRecursive(root, container);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
container.AssignRelationalHierarchy(root, includeInactiveChildren);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
private static IRelationalComponentAssigner ResolveAssigner(Container container)
|
|
183
|
+
{
|
|
184
|
+
if (container == null)
|
|
185
|
+
{
|
|
186
|
+
return null;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
if (container.HasBinding<IRelationalComponentAssigner>())
|
|
190
|
+
{
|
|
191
|
+
return container.Resolve<IRelationalComponentAssigner>();
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
return null;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
#endif
|