diff --git a/.gitignore b/.gitignore index 1660e0b..29b263a 100644 --- a/.gitignore +++ b/.gitignore @@ -74,10 +74,10 @@ mono_crash.* *.unitypackage.meta *.app -# Windows Git matches the macOS bundle pattern case-insensitively. Keep the -# namespace-suffixed Unity package in source control. -!Assets/Modules/ShrinkDataSaver.Integration.App/ -!Assets/Modules/ShrinkDataSaver.Integration.App/** +# Windows Git matches the macOS bundle pattern case-insensitively. Keep all +# namespace-suffixed Unity Integration.App packages in source control. +!Assets/Modules/*.Integration.App/ +!Assets/Modules/*.Integration.App/** # Crashlytics generated file crashlytics-build.properties diff --git a/Assets/Demos/Demo2/Runtime/Demo2AppIntegration.cs b/Assets/Demos/Demo2/Runtime/Demo2AppIntegration.cs index 3f81fb4..9ee96a0 100644 --- a/Assets/Demos/Demo2/Runtime/Demo2AppIntegration.cs +++ b/Assets/Demos/Demo2/Runtime/Demo2AppIntegration.cs @@ -56,8 +56,19 @@ namespace Demo2.Runtime ShrinkAppLoaderBootstrapper.DefaultComposition = host => { previous?.Invoke(host); - if (host.ModuleIds.Contains("demo2.rule-factory")) host.OverrideModuleComponent("demo2.rule-factory", static () => new Demo2AppComponent()); + RegisterOrReplace(host, "demo2.rule-factory", static () => new Demo2AppComponent()); }; } + + private static void RegisterOrReplace( + ShrinkAppLoaderHost host, + string moduleId, + System.Func componentFactory) + { + if (host.ModuleIds.Contains(moduleId, System.StringComparer.OrdinalIgnoreCase)) + host.OverrideModuleComponent(moduleId, componentFactory); + else + host.AddModuleComponent(moduleId, componentFactory); + } } } diff --git a/Assets/Demos/Demo2/Tests/PlayMode/Demo2.PlayMode.Tests.asmdef b/Assets/Demos/Demo2/Tests/PlayMode/Demo2.PlayMode.Tests.asmdef index d9ba45d..05e7eac 100644 --- a/Assets/Demos/Demo2/Tests/PlayMode/Demo2.PlayMode.Tests.asmdef +++ b/Assets/Demos/Demo2/Tests/PlayMode/Demo2.PlayMode.Tests.asmdef @@ -5,6 +5,8 @@ "Demo2.Domain", "Demo2.ECS", "Demo2.Runtime", + "ShrinkApp.Core.Runtime", + "ShrinkContext.AppAdapter.Runtime", "Unity.Entities", "Unity.Collections" ], diff --git a/Assets/Demos/Demo2/Tests/PlayMode/Demo2PlayModeTests.cs b/Assets/Demos/Demo2/Tests/PlayMode/Demo2PlayModeTests.cs index 54a5ec5..6ba974f 100644 --- a/Assets/Demos/Demo2/Tests/PlayMode/Demo2PlayModeTests.cs +++ b/Assets/Demos/Demo2/Tests/PlayMode/Demo2PlayModeTests.cs @@ -6,6 +6,7 @@ using Demo2.Domain; using Demo2.ECS; using Demo2.Runtime; using NUnit.Framework; +using ShrinkContext.AppAdapter; using Unity.Entities; using UnityEngine; using UnityEngine.SceneManagement; @@ -23,6 +24,16 @@ namespace Demo2.Tests yield return null; var controller = Object.FindObjectOfType(); Assert.That(controller, Is.Not.Null); + for (var frame = 0; frame < 30 && + (ShrinkAppLoaderBootstrapper.Instance == null || !ShrinkAppLoaderBootstrapper.Instance.Host.IsRunning); + frame++) + yield return null; + var appHost = ShrinkAppLoaderBootstrapper.Instance; + Assert.That(appHost, Is.Not.Null); + Assert.That(appHost!.Host.IsRunning, Is.True); + Assert.That(appHost.Host.ActiveModuleIds, Does.Contain("demo2.rule-factory")); + Assert.That(appHost.Host.Services.TryGet(out var appService), Is.True); + Assert.That(appService, Is.Not.Null); var document = controller!.GetComponentInChildren(); Assert.That(document, Is.Not.Null); var solo = document!.rootVisualElement.Q