unity-performance
БесплатноБез исполняемых скриптовНе проверенUnity performance optimization for slow games, stutters, and FPS drops. PROACTIVELY activate for: (1) game is slow, stuttering, or has FPS drops, (2) Unity…
от JosiahSiegel★ 67 звёзд на GitHubОб этом скилле
Unity Performance Optimization
Overview
Systematic approach to profiling and optimizing Unity games. Covers profiling tools, CPU/GPU optimization, memory management, rendering optimization, and platform-specific considerations.
Profiling Tools
| Tool | What It Shows | When to Use |
|---|---|---|
| Unity Profiler | CPU, GPU, memory, audio, physics per frame | First stop for any perf issue |
| Frame Debugger | Draw call breakdown, shader/material state | Rendering bottlenecks |
| Memory Profiler | Heap snapshots, texture/mesh memory | Memory leaks, bloat |
| Profile Analyzer | Compare captures, statistical analysis | Before/after optimization |
| Physics Debugger | Collider visualization, contact points | Physics performance |
Profiler Workflow
- Build with Development Build + Autoconnect Profiler enabled
- Profile on target device (not in Editor -- Editor overhead distorts results)
- Identify the bottleneck category: CPU-bound, GPU-bound, or memory pressure
- Drill into the specific system causing the issue
- Optimize, re-profile, and compare
Reading the Profiler
If frame time > 16.6ms (60 FPS target):
CPU timeline > GPU timeline -> CPU-bound
GPU timeline > CPU timeline -> GPU-bound
GC.Alloc column shows per-frame allocations -> GC pressure
Look for spikes (single bad frames) vs. sustained high times (baseline too heavy).
CPU Optimization
Reduce Per-Frame Allocations (GC)
| Anti-Pattern | Fix |
|---|---|
string + string in Update |
Use StringBuilder or cache |
new List<T>() every frame |
Allocate once, Clear() and reuse |
| LINQ in hot paths | Replace with manual loops |
GetComponent<T>() per frame |
Cache in Awake/Start |
GameObject.Find() per frame |
Cache reference or use events |
foreach on non-generic collections |
Use for loop or generic collections |
SendMessage() / BroadcastMessage() |
Use direct calls, events, or interfaces |
| Boxing value types | Use generic collections, avoid object casts |
Object Pooling
public class ObjectPool<T> where T : Component
{
readonly Queue<T> _pool = new();
readonly T _prefab;
readonly Transform _parent;
public ObjectPool(T prefab, int preWarm, Transform parent = null)
{
_prefab = prefab;
_parent = parent;
for (int i = 0; i < preWarm; i++)
_pool.Enqueue(CreateInstance());
}
public T Get(Vector3 position, Quaternion rotation)
{
var obj = _pool.Count > 0 ? _pool.Dequeue() : CreateInstance();
obj.transform.SetPositionAndRotation(position, rotation);
obj.gameObject.SetActive(true);
return obj;
}
public void Return(T obj)
{
obj.gameObject.SetActive(false);
_pool.Enqueue(obj);
}
T CreateInstance()
{
var obj = Object.Instantiate(_prefab, _parent);
obj.gameObject.SetActive(false);
return obj;
}
}
Pool bullets, particles, enemies, UI elements -- anything instantiated/destroyed frequently. Unity 2021+ also has UnityEngine.Pool.ObjectPool<T> built-in.
Update Optimization
| Technique | Description |
|---|---|
| Stagger updates | Don't update all AI every frame; use tick groups |
| Distance-based LOD | Reduce update frequency for distant objects |
| Event-driven | Replace polling with events where possible |
| Disable unused scripts | enabled = false on off-screen components |
Use InvokeRepeating |
For periodic checks (cheaper than coroutine yielding) |
GPU / Rendering Optimization
Draw Call Reduction
| Technique | How | Savings |
|---|---|---|
| Static Batching | Mark non-moving objects as Static | Combines meshes at build time |
| Dynamic Batching | Automatic for small meshes (<300 verts) | URP/Built-in only |
| GPU Instancing | Enable on materials for repeated objects | Trees, grass, rocks |
| SRP Batcher | Enabled by default in URP/HDRP | Reduces SetPass calls |
| Texture Atlasing | Combine textures into atlas | Fewer material switches |
| Mesh Combining | CombineMeshes() at runtime |
Custom batching |
LOD (Level of Detail)
LOD Group Setup:
LOD 0 (0-30%): Full-detail mesh (5000 tris)
LOD 1 (30-60%): Medium mesh (2000 tris)
LOD 2 (60-90%): Low mesh (500 tris)
Culled (90%+): Not rendered
Use LOD for meshes, but also reduce script complexity, particle counts, and physics at distance.
Occlusion Culling
Bake occlusion data for indoor/complex scenes. Mark large static occluders (walls, floors). Configure cell size based on scene scale. Use the Occlusion Culling window to visualize and test.
Shader Optimization
| Issue | Solution |
|---|---|
| Complex fragment shaders | Reduce texture samples, simplify math |
| Overdraw | Minimize transparent objects, use opaque when possible |
| Too many variants | Strip unused sha |
Установить unity-performance в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл unity-performance?
Unity performance optimization for slow games, stutters, and FPS drops. PROACTIVELY activate for: (1) game is slow, stuttering, or has FPS drops, (2) Unity Profiler analysis, (3) Frame Debugger and draw-call investigation, (4) batching (static, dynamic, GPU instancing, SRP Batcher), (5) object pooling to reduce GC pressure, (6) garbage collection spikes and allocation hot paths, (7) memory leaks and Memory Profiler usage, (8) LOD and occlusion culling, (9) texture compression and mipmap settings, (10) build size reduction. Provides: profiling workflow, batching patterns, object-pool implementations, GC reduction techniques, LOD/culling setup, and texture-compression matrix.
Как установить скилл unity-performance?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл unity-performance запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
skill-creator
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
от Anthropicdiscernment-nudge
After you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
от Anthropicdata-consolidate
Joins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
от Anthropicinspection-to-capa
Runs the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…
от Anthropic