Skip to content

UniTask

Lightweight, allocation-free async/await for Unity, built on Unity's PlayerLoop.

Stars
11.3k
Forks
1k
Licence
MIT
Language
C#
Last update
1 months ago
Type
Library

What it is

UniTask is a C# library that lets Unity projects use async/await with a lighter-weight task type than the standard Task. It can await Unity's own asynchronous operations, coroutines, and web requests, and replaces many coroutine-style waits with simple method calls. It runs on Unity's main loop rather than background threads, which is why the README says it also works on WebGL.

  • Await Resources.LoadAsync or SceneManager.LoadSceneAsync without writing coroutines
  • Replace yield return WaitForSeconds with await UniTask.Delay
  • Run several web requests in parallel with UniTask.WhenAll and collect their results
  • Cancel an async operation automatically when a GameObject is destroyed

Great for

  • Unity developers who already use coroutines and want async/await instead
  • Projects that load assets or web requests and need to await them cleanly
  • Teams targeting WebGL or other platforms where threads are unavailable
  • Developers who want to keep allocations low in frequently called code

Not ideal for

  • Projects not using Unity, since the library is built around Unity's PlayerLoop and APIs (the README mentions .NET Core support only in a section it does not show here)
  • Beginners new to both C# and async programming, who may find the wide API surface hard to learn quickly
  • Code that needs real multithreaded parallel work as its main goal, since UniTask deliberately avoids threads by default
Step-by-step guide: how to use UniTaskInstall, first run, examples, tips and FAQs

How to get it

  1. 1

    Install with a package manager

    You'll need: Unity (minimum version: the README says after Unity 2018.3, with 2018.4.13f1 as the lowest officially supported)

    Install via git URL (UPM package)

    git clone https://github.com/Cysharp/UniTask.git
  2. 2

    Run it

    • Install UniTask through the Unity Package Manager using a git reference, or import the UniTask .unitypackage from the releases page.
    • Add `using Cysharp.Threading.Tasks;` at the top of your C# script.
    • Mark a method as `async UniTask` and await a Unity operation such as Resources.LoadAsync.
    • Try UniTask.Delay or UniTask.Yield in place of a coroutine wait to see the difference.
  3. 3

    Get the most out of it

    • Pass this.GetCancellationTokenOnDestroy() or destroyCancellationToken to WithCancellation so tasks stop when objects are destroyed.
    • Use Progress.Create with ToUniTask to report progress from long loads.
    • Use UniTask.WhenAll and tuple deconstruction to run and collect several async results at once.
    • Enable the TaskTracker window (mentioned in the README) to help find leaked tasks.

Downloads

Strengths

  • The README describes struct-based UniTask<T> designed for zero allocation
  • Works on Unity's PlayerLoop, so it does not depend on threads and supports WebGL and wasm
  • Covers many Unity waits (frames, yields, WaitUntil, WaitForEndOfFrame) in one API

Trade-offs

  • Requires understanding of async/await and Unity's PlayerLoop timing to use correctly
  • The README is long and the API surface is large; this entry only covers the opening section
  • Behaviour depends on Unity version (for example, destroyCancellationToken needs Unity 2022.2 or newer, per the README)

How it compares

ProjectStarsTypeLevelUpdatedBest for
UniTask (this)11.3kLibraryintermediate1 months agoUnity developers who already use coroutines and want async/await instead
roslyn20.8kLibraryadvanced4 days agoDevelopers building code analysis or refactoring tools for .NET
AssetStudio15.6kAppintermediate3.9 years agoDevelopers who want to inspect the contents of Unity asset bundles
spectre.console11.7kLibrarybeginner11 days agoC# or .NET developers writing command-line tools
BenchmarkDotNet11.5kLibraryintermediate5 days ago.NET developers who want to compare two or more implementations of a method
Terminal.Gui11.3kLibraryintermediate6 days agoC# / .NET developers building terminal tools with forms, tables or menus

Stats synced from GitHub. The assessment above was drafted with AI from the project's README on 2026-10-29 and may miss recent changes — check the README before relying on a command. MIT licence: free to use, modify and distribute, including commercially, as long as you keep the copyright notice.