diff --git a/CHANGELOG.md b/CHANGELOG.md index 1dc34de..df7ef37 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,11 +1,12 @@ # Microsoft.Extensions.Hosting for Unity -## [2.1.0] - 2023-04-09 +## [2.1.0] - 2023-05-03 ### Added - Scoped MonoBehaviours -- MonoBehaviour prefabs registration by prefab name from Resources -- ScriptableObjectConfiguration as configuration source +- `MonoBehaviour` prefabs registration by prefab name from Resources +- `ScriptableObjectConfiguration` as configuration source - hostBuilding event when the host is being built +- `StopManuallyAsync` method to `HostManager` ### Updated - make HostManager events public diff --git a/Runtime/HostManager.cs b/Runtime/HostManager.cs index b15c210..e203659 100644 --- a/Runtime/HostManager.cs +++ b/Runtime/HostManager.cs @@ -195,7 +195,7 @@ public void StartManually() } /// - /// Start the Host manually. + /// Stop the Host manually. /// /// when the Host was not build and started yet. public void StopManually() @@ -209,6 +209,24 @@ public void StopManually() host.StopAsync().GetAwaiter().GetResult(); } } + + /// + /// Stop the Host manually. + /// + /// when the Host was not build and started yet. + public Task StopManuallyAsync() + { + if (!_isBuilt && !_isStarted) + throw new InvalidOperationException("Host must be build and started before stop."); + + if (host != null) + { + _cts?.Cancel(); + return host.StopAsync(); + } + + return Task.CompletedTask; + } #endregion diff --git a/package.json b/package.json index f7bbb0c..8b8f968 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "description": "Microsoft.Extensions.Hosting adopted for Unity", "unity": "2021.1", "release": "0f1", - "version": "2.1.0-preview.3", + "version": "2.1.0-preview.4", "keywords": [ "unity", "integration",