Repolode
Cysharp

Cysharp/UniTask

Allocation-free async/await integration for Unity that makes Unity async operations, coroutines and PlayerLoop timing awaitable.

Stars
11,256
Forks
1,012
Open issues
26
Last commit
13 days ago

What is it?

UniTask is a Unity-specific task type and async/await integration. It provides a struct-based UniTask<T> with a custom async method builder aimed at zero allocation, as an alternative to the standard Task. Unity's AsyncOperations, coroutines and UnityWebRequest requests can be awaited directly, and frame-based waits such as Yield, Delay and DelayFrame replace common coroutine patterns.

The library runs entirely on Unity's PlayerLoop rather than threads, so it works on platforms such as WebGL and WASM. It also covers cancellation and timeouts through CancellationToken, MonoBehaviour message events and uGUI events as awaitable or async-enumerable streams, and asynchronous LINQ with Channel and AsyncReactiveProperty. A TaskTracker editor window helps locate leaked tasks.

UniTask requires Unity 2018.3 or newer with C# 7.0 task-like builder support, and can be installed through UPM via git URL or from a unitypackage release.

Key features

  • 01Struct-based UniTask<T> with a custom async builder designed for zero allocation.
  • 02Direct await support for AsyncOperation, UnityWebRequest and IEnumerator coroutines.
  • 03PlayerLoop-based Yield, Delay and DelayFrame replace common coroutine waits.
  • 04Runs on PlayerLoop without threads, so it works on WebGL and WASM.
  • 05CancellationToken, timeout helpers and a TaskTracker editor window for debugging leaks.
  • 06Asynchronous LINQ, Channel and AsyncReactiveProperty for async streams.

Use cases

  • Replacing coroutines in a Unity game with async/await code.
  • Loading assets or scenes and making web requests in sequence or in parallel inside Unity.
  • Building Unity projects that target WebGL, where threads are unavailable.
  • Converting uGUI button clicks or MonoBehaviour events into awaitable async streams.

Topics

FAQ

What is UniTask?
Allocation-free async/await integration for Unity that makes Unity async operations, coroutines and PlayerLoop timing awaitable. UniTask is a Unity-specific task type and async/await integration. It provides a struct-based UniTask<T> with a custom async method builder aimed at zero allocation, as an alternative to the standard Task. Unity's AsyncOperations, coroutines and UnityWebRequest requests can be awaited directly, and frame-based waits such as Yield, Delay and DelayFrame replace common coroutine patterns.
Is UniTask free to use? What license does it have?
UniTask is open source under the MIT license. Check the license terms before using it in commercial products.
Is UniTask still maintained?
Actively maintained. The last commit to UniTask was on Oct 6, 2026.
What can I use UniTask for?
Replacing coroutines in a Unity game with async/await code. Loading assets or scenes and making web requests in sequence or in parallel inside Unity. Building Unity projects that target WebGL, where threads are unavailable. Converting uGUI button clicks or MonoBehaviour events into awaitable async streams.
Where can I get UniTask?
The source code and installation instructions are on GitHub: https://github.com/Cysharp/UniTask

Summary generated by AI from the project's README. GitHub stats refresh daily.

Related projects