unity-async

Advise scheduling and cleanup strategies for Unity async and per-frame work.

Updated Apr 11, 2026
One-click install
npx skills add https://github.com/lrbjk/FenShen_Remake_V0 --skill unity-async-lrbjk
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: unity-async
Source: https://github.com/lrbjk/FenShen_Remake_V0/tree/main/.codex/skills/unity-skills/skills/async
Command: npx skills add https://github.com/lrbjk/FenShen_Remake_V0 --skill unity-async-lrbjk

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Helps developers choose and justify the appropriate scheduling and cleanup model for runtime work in Unity, reducing bugs from improper lifecycle handling, leaking subscriptions, or inappropriate use of Update/coroutines/third-party async libraries.

Core Features & Use Cases

  • Decision ladder to determine whether work should be event-driven, coroutine-based, per-frame Update, timer-based, or implemented with a task library like UniTask.
  • Lifecycle and cancellation guidance including ownership, subscribe/unsubscribe symmetry (OnEnable/OnDisable/OnDestroy), IDisposable use cases, and hot-path caching recommendations.
  • Use cases: short Unity-bound sequences (coroutines), continuous simulation or input polling (Update), scheduled delayed work (timers), and projects that may accept UniTask as a dependency.

Quick Start

Recommend whether to use Update, coroutine, UniTask, or a timer for a task that runs every frame and explain who should own cancellation and cleanup.

Frequently Asked Questions about unity-async

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
When should I use a Unity coroutine versus Update for per-frame work?

Use Unity coroutines for short sequential animations or delayed logic, and Update for continuous simulation or input polling. Coroutines tie execution to MonoBehaviour lifecycle, making them suitable for time-bound sequences rather than continuous per-frame tracking.

How do I handle cancellation and cleanup for UniTask in Unity MonoBehaviour lifecycles?

Handle UniTask cancellation by defining lifecycle ownership and maintaining subscribe/unsubscribe symmetry across OnEnable, OnDisable, and OnDestroy. Assign cancellation tokens to specific MonoBehaviours and dispose them properly to prevent leaking subscriptions.

Do I need UniTask to manage asynchronous work in Unity, or are native coroutines enough?

You do not need UniTask if native Unity coroutines suffice for your short sequential tasks. UniTask is an optional dependency recommended for projects requiring complex task scheduling, hot-path performance optimizations, or advanced cancellation strategies beyond coroutine capabilities.

What is the best way to schedule delayed work in Unity without leaking subscriptions?

The best way to schedule delayed work in Unity without leaking subscriptions is using timer-based scheduling with strict IDisposable cleanup. Ensure subscription symmetry by unsubscribing during the corresponding MonoBehaviour lifecycle event like OnDisable.

Why does my Unity async pattern cause performance issues in the hot-path update loop?

Your Unity async pattern causes performance issues in the hot-path Update loop due to improper scheduling or missing caching. Choose event-driven work over per-frame polling and cache references to avoid garbage generation and unnecessary computation during continuous execution.