unity-unitask
UniTask library expert specializing in allocation-free async/await patterns, coroutine migration, and Unity-optimized asynchronous programming. Masters UniTask performance optimizations, cancellation handling, and memory-efficient async operations. Use PROACTIVELY for UniTask implementation, async optimization, or coroutine replacement.
Best use case
unity-unitask is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
UniTask library expert specializing in allocation-free async/await patterns, coroutine migration, and Unity-optimized asynchronous programming. Masters UniTask performance optimizations, cancellation handling, and memory-efficient async operations. Use PROACTIVELY for UniTask implementation, async optimization, or coroutine replacement.
Teams using unity-unitask should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/unity-unitask/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How unity-unitask Compares
| Feature / Agent | unity-unitask | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
UniTask library expert specializing in allocation-free async/await patterns, coroutine migration, and Unity-optimized asynchronous programming. Masters UniTask performance optimizations, cancellation handling, and memory-efficient async operations. Use PROACTIVELY for UniTask implementation, async optimization, or coroutine replacement.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# UniTask - High-Performance Async for Unity
## Overview
UniTask is a zero-allocation async/await library optimized for Unity, providing allocation-free asynchronous programming patterns superior to standard C# Task.
**Foundation Required**: `unity-csharp-fundamentals` (TryGetComponent, FindAnyObjectByType), `csharp-async-patterns` (Task, async/await), `unity-async` (Unity async context)
**Core Topics**:
- Allocation-free async/await patterns
- Coroutine to UniTask migration
- PlayerLoop-based execution model
- Memory pool management and GC pressure reduction
- Advanced cancellation and timeout handling
- Integration with Unity systems (Addressables, DOTween, etc.)
**Learning Path**: C# async basics → Unity async context → UniTask optimization → Production patterns
## Quick Start
### UniTask vs Task Performance
```csharp
// Standard Task (allocates memory)
public async Task<int> GetStandard()
{
await Task.Delay(1000);
return 42;
}
// UniTask (zero allocation)
public async UniTask<int> GetOptimized()
{
await UniTask.Delay(1000);
return 42;
}
```
### Basic Patterns
```csharp
// Frame-based delays
await UniTask.Yield(); // Next frame
await UniTask.DelayFrame(10); // Wait 10 frames
await UniTask.NextFrame(); // Explicit next frame
// Time-based delays
await UniTask.Delay(TimeSpan.FromSeconds(1));
await UniTask.WaitForSeconds(1f);
// Unity operations
await Resources.LoadAsync<Sprite>("icon").ToUniTask();
await SceneManager.LoadSceneAsync("Level1").ToUniTask();
// Cancellation
CancellationTokenSource cts = new CancellationTokenSource();
await SomeOperation(cts.Token);
```
## When to Use
### UniTask (This Skill)
- Zero-allocation critical paths (mobile, performance-critical scenarios)
- Memory-efficient async operations
- PlayerLoop timing control and customization
- Coroutine replacement for better performance
- Integration with Unity async operations
### Alternatives
- **unity-async skill**: General Unity async patterns, coroutines, Job System
- **Standard Task**: Cross-platform .NET code, non-performance-critical scenarios
## Reference Documentation
### [UniTask Fundamentals](references/unitask-fundamentals.md)
Core UniTask concepts and migration:
- UniTask vs Task performance characteristics
- Coroutine migration patterns
- PlayerLoop execution model
- Memory pool management
- Basic async operations
### [Performance Optimization](references/performance-optimization.md)
Advanced performance techniques:
- Allocation-free patterns
- GC pressure reduction
- PlayerLoop timing control
- Memory profiling with UniTask.Tracker
- Burst-compatible async patterns
### [Integration Patterns](references/integration-patterns.md)
Unity system integrations:
- Addressables async loading
- DOTween integration
- UnityWebRequest patterns
- UI event handling
- AsyncReactiveProperty usage
## Key Principles
1. **Zero-Allocation Focus**: UniTask eliminates allocations for async operations
2. **PlayerLoop Integration**: Tight Unity integration for optimal performance
3. **Always Support Cancellation**: Use `this.GetCancellationTokenOnDestroy()` for MonoBehaviour lifecycle
4. **Prefer UniTask over Task**: Better performance and Unity compatibility
5. **Profile Memory Usage**: Use UniTask.Tracker to monitor active tasks and memory
## Common Patterns
### Automatic Cancellation with MonoBehaviour
```csharp
public class Example : MonoBehaviour
{
async UniTaskVoid Start()
{
// Auto-cancels when GameObject is destroyed
await LoadData(this.GetCancellationTokenOnDestroy());
}
}
```
### Parallel Operations
```csharp
// Execute multiple operations in parallel
(int result1, string result2, float result3) = await UniTask.WhenAll(
Operation1(),
Operation2(),
Operation3()
);
```
### Timeout Handling
```csharp
CancellationTokenSource cts = new CancellationTokenSource();
cts.CancelAfterSlim(TimeSpan.FromSeconds(5)); // PlayerLoop-based
try
{
await LongOperation(cts.Token);
}
catch (OperationCanceledException)
{
Debug.Log("Operation timed out");
}
```
## Platform Considerations
- **WebGL**: Limited threading, UniTask provides frame-based async as primary pattern
- **Mobile**: Critical for battery optimization and memory efficiency
- **Desktop**: Full feature support with optimal performance
## Best Practices
1. **Use CancellationToken**: Always pass cancellation tokens, prefer `this.GetCancellationTokenOnDestroy()`
2. **Avoid async void**: Use `UniTaskVoid` for fire-and-forget operations
3. **PlayerLoop Optimization**: Use minimal PlayerLoop injection for better performance
4. **Profile with Tracker**: Monitor memory with `UniTask.Tracker` in editor
5. **Chain Operations**: Use `WhenAll`/`WhenAny` for parallel execution
6. **Thread Switching**: Use `SwitchToMainThread()`/`SwitchToThreadPool()` appropriately
## Integration with Other Skills
- **unity-async**: Provides foundation for Unity async patterns
- **unity-reactive**: AsyncReactiveProperty bridges UniTask with R3
- **unity-di**: UniTask works seamlessly with VContainer DI patterns
- **unity-performance**: UniTask reduces GC pressure significantlyRelated Skills
unity-ecs-patterns
Master Unity ECS (Entity Component System) with DOTS, Jobs, and Burst for high-performance game development. Use when building data-oriented games, optimizing performance, or working with large ent...
unity-developer
Build Unity games with optimized C# scripts, efficient rendering, and proper asset management. Masters Unity 6 LTS, URP/HDRP pipelines, and cross-platform deployment. Handles gameplay systems, UI implementation, and platform optimization. Use PROACTIVELY for Unity performance issues, game mechanics, or cross-platform builds.
regulatory-community-analysis-ChIA-PET
This skill performs protein-mediated regulatory community analysis from ChIA-PET datasets and provide a way for visualizing the communities. Use this skill when you have a annotated peak file (in BED format) from ChIA-PET experiment and you want to identify the protein-mediated regulatory community according to the BED and BEDPE file from ChIA-PET.
brand-guidelines-community
Applies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatt...
unity-skill
Enables AI agents to control Unity Editor via HTTP bridge. Injects AI service scripts into Unity projects for remote command execution (create/delete objects, modify scenes, query hierarchy). Use when working with Unity projects or when user requests Unity scene manipulation.
ops-automation-opportunity-finder
Identify and evaluate automation opportunities in banking operations using structured assessment frameworks. Use when analyzing processes for RPA, intelligent automation, AI/ML, or straight-through processing potential across payments, lending, account servicing, compliance, and back-office functions.
community-monetization
When the user wants to monetize their community through paid memberships, sponsorships, premium tiers, or other revenue models. Also use when the user mentions 'paid community,' 'monetize community,' 'community revenue,' 'sponsorship,' 'premium tier,' 'community subscription,' 'membership fee,' or 'community business model.' For community as a business growth engine, see community-led-growth.
startup-business-analyst-market-opportunity
Generate comprehensive market opportunity analysis with TAM/SAM/SOM calculations
internal-comms-community
A set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill whenever asked to write some sort of internal ...
bgo
Automates the complete Blender build-go workflow, from building and packaging your extension/add-on to removing old versions, installing, enabling, and launching Blender for quick testing and iteration.
upgrading-expo
Upgrade Expo SDK versions
upgrade-stripe
Guide for upgrading Stripe API versions and SDKs