-
-
Notifications
You must be signed in to change notification settings - Fork 938
-
Hello everyone Faced with such a problem after upgrading to Unity3D 202310.b18:
error CS0121: The call is ambiguous between the following methods or properties: 'Cysharp.Threading.Tasks.UnityAsyncExtensions.GetAwaiter(UnityEngine.AsyncOperation)' and 'UnityEngine.AsyncOperationAwaitableExtensions.GetAwaiter(UnityEngine.AsyncOperation)'
My code:
await UnityEngine.SceneManagement.SceneManager.LoadSceneAsync(ID);
``
I solved this problem in this way if anyone needs:
AsyncOperation loadSceneHandler = UnityEngine.SceneManagement.SceneManager.LoadSceneAsync(ID);
await loadSceneHandler.ToUniTask();
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 2 comments 5 replies
-
Warning
From the UniTask Readme:
In UniTask, await directly uses native timing, while WithCancellation and ToUniTask use specified timing. This is usually not a particular problem, but with LoadSceneAsync, it causes a different order of Start and continuation after await. So it is recommended not to use LoadSceneAsync.ToUniTask.
At first I used this and it seemed to work fine in editor and standalone windows builds. But when I tested in a UWP build (IL2CPP), the await loadSceneHandler.ToUniTask();
hold the whole app and all I got was a black screen.
Beta Was this translation helpful? Give feedback.
All reactions
-
UnityAsyncExtensions.GetAwaiter is disabled in UNITY_2023_1_OR_NEWER
.
UniTask/src/UniTask/Assets/Plugins/UniTask/Runtime/UnityAsyncExtensions.cs
Lines 18 to 25 in 0c8057c
Why is it enabled?
Beta Was this translation helpful? Give feedback.
All reactions
-
I don't know...
I'm using Unity 2023年1月16日f1 and have the name conflict.
It seems UNITY_2023_1_OR_NEWER
is false in my project (so the code is included), this is very strange.
Beta Was this translation helpful? Give feedback.
All reactions
-
My issue is with Visual Studio.
The define are not properly set, so Visual Studio underline await SceneManager.UnloadSceneAsync("my_scene_name");
in red with error CS0121, but it's ok in Unity.
Beta Was this translation helpful? Give feedback.
All reactions
-
How about regenerating csproj?
Delete the sln and csproj and have Unity regenerate them.
Beta Was this translation helpful? Give feedback.
All reactions
-
Already done, and it doesn't fix preprocessor directives in Visual Studio.
I think it's because of some incompatibility of my Visual Studio version and the Unity Visual Studio package version, but I can't change easily them becuse my company computer doesn't have an access to the internet.
It's not a big issue for me, now I understood it's broken only in Visual Studio.
Beta Was this translation helpful? Give feedback.
All reactions
-
I know I'm late to the conversation but in case it happens to someone else:
You need to set using UnityEngine;
in the class you are setting your await
or else it will try to get the AsyncOperation
from LoadSceneAsync
instead of the Awaitable
version from Unity
Beta Was this translation helpful? Give feedback.