Skip to content

Commit

Permalink
Merge pull request #31 from mewlist/through-already-unloaded-scene-ref
Browse files Browse the repository at this point in the history
Pass to unlaod already unloaded scene reference
  • Loading branch information
mewlist authored Feb 23, 2024
2 parents 406d0ad + a8b2f78 commit 1cabd20
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion Runtime/Assets/Scene/UnifiedSceneLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#if USE_MEW_CORE_ASSETS
using UnityEngine.AddressableAssets;
using UnityEngine.ResourceManagement.ResourceProviders;
#endif

#if UNITY_EDITOR
Expand Down Expand Up @@ -71,8 +72,19 @@ public static async ValueTask UnloadAsync(ISceneHandle targetHandle)
#if USE_MEW_CORE_ASSETS
case SceneInstanceHandle sceneInstanceHandle:
{
SceneInstance sceneInstance;
try
{
sceneInstance = sceneInstanceHandle.Handle.Result;
}
catch (Exception)
{
// Scene is already unloaded
return;
}

var handle = Addressables.UnloadSceneAsync(
sceneInstanceHandle.Handle.Result,
sceneInstance,
UnloadSceneOptions.UnloadAllEmbeddedSceneObjects,
true);
await handle.Task;
Expand Down

0 comments on commit 1cabd20

Please sign in to comment.