Skip to content

Commit

Permalink
fix: use of await AsyncOperation in unity 2023 (#1151)
Browse files Browse the repository at this point in the history
Unity added GetAwaiter to AsyncOperation which conflicts with the UniTask GetAwaiter. To fix this we can first call ToUniTask, this should work in earlier versions of unity too.
  • Loading branch information
Moddingdudes committed Jun 23, 2023
1 parent a0fd6f5 commit 5af1435
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Assets/Mirage/Runtime/NetworkSceneManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -822,7 +822,7 @@ private async UniTask LoadSceneNormalAsync(string scenePath, LoadSceneParameters
SceneLoadingAsyncOperationInfo.allowSceneActivation = false;
}

await SceneLoadingAsyncOperationInfo;
await SceneLoadingAsyncOperationInfo.ToUniTask();
AssertSceneIsActive(scenePath);

CompleteLoadingScene(SceneManager.GetActiveScene(), SceneOperation.Normal);
Expand All @@ -848,7 +848,7 @@ private async UniTask LoadSceneAdditiveAsync(string scenePath, IEnumerable<INetw
? SceneManager.LoadSceneAsync(scenePath, sceneLoadParameters.Value)
: SceneManager.LoadSceneAsync(scenePath, LoadSceneMode.Additive);

await SceneLoadingAsyncOperationInfo;
await SceneLoadingAsyncOperationInfo.ToUniTask();

var scene = SceneManager.GetSceneAt(SceneManager.sceneCount - 1);

Expand All @@ -871,7 +871,7 @@ private async UniTask UnLoadSceneAdditiveAsync(string scenePath)
var scene = SceneManager.GetSceneByPath(scenePath);
if (scene.IsValid())
{
await SceneManager.UnloadSceneAsync(scenePath, UnloadSceneOptions.UnloadAllEmbeddedSceneObjects);
await SceneManager.UnloadSceneAsync(scenePath, UnloadSceneOptions.UnloadAllEmbeddedSceneObjects).ToUniTask();

CompleteLoadingScene(scene, SceneOperation.UnloadAdditive);
}
Expand All @@ -890,7 +890,7 @@ private async UniTask UnLoadSceneAdditiveAsync(Scene scene)
// Ensure additive scene is actually loaded
if (scene.IsValid())
{
await SceneManager.UnloadSceneAsync(scene, UnloadSceneOptions.UnloadAllEmbeddedSceneObjects);
await SceneManager.UnloadSceneAsync(scene, UnloadSceneOptions.UnloadAllEmbeddedSceneObjects).ToUniTask();

CompleteLoadingScene(scene, SceneOperation.UnloadAdditive);
}
Expand Down

0 comments on commit 5af1435

Please sign in to comment.