Cancelling SceneManager.LoadSceneAsync() / .UnloadSceneAsync() that has been converted to UniTask #513
Replies: 1 comment
|
For a normal Unity When cancellation is detected, the UniTask completes as cancelled, but there is no call in the wrapper that aborts the original Unity operation. So: await SceneManager.LoadSceneAsync(...)
.WithCancellation(token);means roughly: not: The underlying That also means UniTask does not automatically:
For a scene-management system I would therefore treat cancellation as cancellation of the request/caller, not cancellation of Unity's scene operation. If a load becomes obsolete, one possible pattern is to associate each request with a generation/request ID, allow Unity's This is especially relevant with |
Uh oh!
There was an error while loading. Please reload this page.
I've tried reading the documentation, I looked through the discussions here and googled it but i couldn't find an answer to this. So I'll just have to ask it here.
I am making a scene managing solution for my projects so my question is: How does UniTask handle cancellation of scene loading?
for a little context. In normal unity behavior it is impossible to cancel loading and unloading. And in async the async methods, if the scenes are loaded and not enabled the
AsyncOperationwill still be active since the scenes are not enabled and stays on 0.9 completion. Only way to complete the operation is to enable the scenes, and then let theAsyncOperationcomplete. Until the operation is done the scene can not be unloaded. which means it has to become enabled before it can be unloaded.UniTask can convert these methods and let them be handled with cancellation tokens. But the question still remains, is the rest of the default unity scene handling functioning as before or does UniTask handle the cancelled scene? unloading it if it was supposed to load, or loading it back in if it was unloading?
Either way I'm questioning if cancelling loading is a feature i even need or if it would even be used. But I've seen how useful UniTask can be so i was curious on if it could work.
Thanks!
All reactions