Skip to content

fix(core): convert AsyncOperation to UniTask for Unity 6 compatibility#594

Closed
JasonXuDeveloper wants to merge 1 commit into
masterfrom
fix/unity6-asyncoperation-await
Closed

fix(core): convert AsyncOperation to UniTask for Unity 6 compatibility#594
JasonXuDeveloper wants to merge 1 commit into
masterfrom
fix/unity6-asyncoperation-await

Conversation

@JasonXuDeveloper

Copy link
Copy Markdown
Owner

Summary

  • Fix CS0311 compilation error in Unity 6 where UnityEngine.AsyncOperation cannot be directly awaited
  • Convert SceneManager.LoadSceneAsync() to use .ToUniTask() extension method

Problem

In Unity 6, UnityEngine.AsyncOperation cannot be used as a type parameter for EnumeratorAsyncExtensions.GetAwaiter<T>() because there's no implicit reference conversion to System.Collections.IEnumerator.

Solution

Use the ToUniTask() extension method from Cysharp.Threading.Tasks to convert the AsyncOperation to a UniTask, which can be awaited. This pattern is already used elsewhere in the codebase (e.g., line 145 in the same file).

Test plan

  • Open the project in Unity 6
  • Verify no CS0311 compilation errors
  • Test scene loading error path to ensure fallback scene loads correctly

🤖 Generated with Claude Code

In Unity 6, UnityEngine.AsyncOperation cannot be directly awaited.
Convert to UniTask using .ToUniTask() extension method.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: JasonXuDeveloper - 傑 <jason@xgamedev.net>
Copilot AI review requested due to automatic review settings January 28, 2026 22:39
@github-actions github-actions Bot added the core label Jan 28, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes Unity 6 compilation (CS0311) by converting UnityEngine.AsyncOperation returned from SceneManager.LoadSceneAsync() into an awaitable UniTask via .ToUniTask().

Changes:

  • Replace direct await on SceneManager.LoadSceneAsync() with await ...ToUniTask() in the error recovery path.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@JasonXuDeveloper JasonXuDeveloper deleted the fix/unity6-asyncoperation-await branch January 28, 2026 22:41
@github-actions

Copy link
Copy Markdown

Unity Test Results

EditMode: All tests passed
PlayMode: All tests passed

Unity Version: 2022.3.55f1
Project Path: UnityProject

✅ All tests passed! The PR is ready for review.

View workflow run

Click here to view the full workflow run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants