From unity-plugin
Provides UniTask expertise for allocation-free async/await in Unity, coroutine migration to UniTask, performance optimizations, and memory-efficient async operations.
npx claudepluginhub creator-hian/claude-code-plugins --plugin unity-pluginThis skill uses the workspace's default tool permissions.
UniTask is a zero-allocation async/await library optimized for Unity, providing allocation-free asynchronous programming patterns superior to standard C# Task.
Unity async and coroutine correctness patterns. Catches common mistakes with Awaitable double-await, missing cancellation tokens, thread context after BackgroundThreadAsync, coroutine error swallowing, batch mode WaitForEndOfFrame, and Addressables handle leaks. PATTERN format: WHEN/WRONG/RIGHT/GOTCHA. Based on Unity 6.3 LTS documentation.
Provides Unity C# scripting patterns covering MonoBehaviour lifecycle, coroutines, async/await, physics APIs, raycasts, collisions, animations, NavMesh, pooling, singletons, ECS, Jobs, and Burst.
Provides production patterns for Unity DOTS including Entity Component System, Job System, and Burst Compiler. Use for high-performance games, efficient entity management, data-oriented systems, and CPU optimization.
Share bugs, ideas, or general feedback.
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:
Learning Path: C# async basics → Unity async context → UniTask optimization → Production patterns
// 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;
}
// 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);
Core UniTask concepts and migration:
Advanced performance techniques:
Unity system integrations:
this.GetCancellationTokenOnDestroy() for MonoBehaviour lifecyclepublic class Example : MonoBehaviour
{
async UniTaskVoid Start()
{
// Auto-cancels when GameObject is destroyed
await LoadData(this.GetCancellationTokenOnDestroy());
}
}
// Execute multiple operations in parallel
(int result1, string result2, float result3) = await UniTask.WhenAll(
Operation1(),
Operation2(),
Operation3()
);
CancellationTokenSource cts = new CancellationTokenSource();
cts.CancelAfterSlim(TimeSpan.FromSeconds(5)); // PlayerLoop-based
try
{
await LongOperation(cts.Token);
}
catch (OperationCanceledException)
{
Debug.Log("Operation timed out");
}
this.GetCancellationTokenOnDestroy()UniTaskVoid for fire-and-forget operationsUniTask.Tracker in editorWhenAll/WhenAny for parallel executionSwitchToMainThread()/SwitchToThreadPool() appropriately