-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from mackysoft/fix/blank-scene-active
Navigathema blank scene is now unloaded when scene loaded
- Loading branch information
Showing
4 changed files
with
62 additions
and
1 deletion.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
...ft.Navigathena/Runtime/SceneManagement/SceneIdentifier/NavigathenaBlankSceneIdentifier.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
using System; | ||
using System.Threading; | ||
using Cysharp.Threading.Tasks; | ||
using UnityEngine.SceneManagement; | ||
|
||
namespace MackySoft.Navigathena.SceneManagement | ||
{ | ||
internal sealed class NavigathenaBlankSceneIdentifier : ISceneIdentifier | ||
{ | ||
|
||
public static readonly NavigathenaBlankSceneIdentifier Instance = new NavigathenaBlankSceneIdentifier(); | ||
|
||
public ISceneHandle CreateHandle () | ||
{ | ||
return NavigathenaBlankSceneHandle.Instance; | ||
} | ||
|
||
sealed class NavigathenaBlankSceneHandle : ISceneHandle | ||
{ | ||
|
||
public static readonly NavigathenaBlankSceneHandle Instance = new NavigathenaBlankSceneHandle(); | ||
|
||
const string kSceneName = "Navigathena Blank"; | ||
|
||
public UniTask<Scene> Load (IProgress<float> progress = null, CancellationToken cancellationToken = default) | ||
{ | ||
if (SceneManager.GetSceneByName(kSceneName).IsValid()) | ||
{ | ||
return UniTask.FromResult(SceneManager.GetSceneByName(kSceneName)); | ||
} | ||
return UniTask.FromResult(SceneManager.CreateScene(kSceneName)); | ||
} | ||
|
||
public async UniTask Unload (IProgress<float> progress = null, CancellationToken cancellationToken = default) | ||
{ | ||
Scene scene = SceneManager.GetSceneByName(kSceneName); | ||
if (!scene.isLoaded && !scene.IsValid()) | ||
{ | ||
return; | ||
} | ||
|
||
await SceneManager.UnloadSceneAsync(kSceneName) | ||
.ToUniTask(progress, cancellationToken: cancellationToken); | ||
} | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...vigathena/Runtime/SceneManagement/SceneIdentifier/NavigathenaBlankSceneIdentifier.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters