explaingit

cysharp/unitask

10,800C#Audience · developerComplexity · 3/5Setup · moderate

TLDR

A C# library for Unity that replaces coroutines with async/await code that produces zero heap allocations, keeping games running smoothly while making asynchronous logic easier to read and maintain.

Mindmap

mindmap
  root((UniTask))
    What it does
      Async await in Unity
      Zero heap allocations
      Replace coroutines
    Features
      Await any Unity op
      Async LINQ
      TaskTracker window
    Compatibility
      Unity 2018.3 plus
      WebGL support
      .NET Task compatible
    Audience
      Unity developers
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Replace Unity coroutines with async/await methods that are easier to read and produce no garbage-collection pauses during gameplay.

USE CASE 2

Await asset loading, web requests, or scene transitions in Unity without writing nested callbacks or IEnumerator methods.

USE CASE 3

Use the built-in TaskTracker editor window to find async operations that started but never completed, fixing memory leaks before they ship.

Tech stack

C#Unity

Getting it running

Difficulty · moderate Time to first run · 30min

Install via Unity Package Manager using the git URL, requires Unity 2018.3 or later.

In plain English

UniTask is a C# library for Unity that gives you a cleaner way to write asynchronous code in your game or application. Instead of relying on coroutines or Unity's older async patterns, you can use async/await syntax, which lets you express step-by-step operations in a readable, sequential style without callback nesting. The core design goal is to avoid wasting memory. Standard C# tasks allocate memory on the heap each time they run, which can cause slowdowns in games that need consistent frame rates. UniTask uses a struct-based design so that awaiting an operation typically produces no heap allocation at all. It integrates directly with Unity's player loop rather than spawning threads, which means it works correctly on platforms like WebGL that do not support threads. Practically speaking, UniTask lets you await almost anything Unity produces: loading assets, web requests, scene transitions, physics updates, and even the old coroutine-style IEnumerator methods. There are also helper methods to replace common coroutine patterns, such as waiting for a fixed number of frames, waiting for a time delay, or waiting until a condition becomes true. For more advanced work, UniTask includes an Async LINQ feature that lets you process sequences of values that arrive over time, similar to how LINQ works on regular collections. There is also a TaskTracker window built into the Unity editor that shows you which tasks are currently running and helps spot ones that were never completed, which is a common source of memory leaks in async Unity code. The library targets Unity 2018.3 and later. It is compatible with the standard .NET Task and ValueTask types, so existing code that already uses those patterns can gradually adopt UniTask without a full rewrite. The full README is longer than what was shown.

Copy-paste prompts

Prompt 1
Using UniTask in Unity, show me how to load an asset with Resources.LoadAsync and await the result with async/await instead of a coroutine.
Prompt 2
How do I convert an existing Unity coroutine written as an IEnumerator into a UniTask so I can await it from an async method?
Prompt 3
In Unity with UniTask, how do I wait for 2 seconds without allocating memory, as a replacement for the WaitForSeconds coroutine pattern?
Prompt 4
UniTask includes Async LINQ. Show me a Unity example where I await a sequence of player input events and process each one as it arrives.
Open on GitHub → Explain another repo

← cysharp on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.