| name | unity-performance-optimization |
| description | Unity Performance Optimization |
Unity Performance Optimization
Use this skill when profiling frame rate issues, reducing draw calls, optimizing memory usage, or addressing CPU/GPU bottlenecks in Unity.
Profiling Workflow
- Identify the bottleneck — Is it CPU, GPU, or memory? Check Profiler.
- Measure — Get a baseline number (ms per frame, draw calls, memory).
- Optimize — Apply the appropriate technique.
- Verify — Re-measure. Did it actually improve? By how much?
- Repeat — Go back to step 1.
Frame budgets:
| Target FPS | Budget per Frame |
|---|
| 30 fps | 33.3 ms |
| 60 fps | 16.6 ms |
| 90 fps (VR) | 11.1 ms |
| 120 fps | 8.3 ms |
LOD Groups
Reduce polygon count for distant objects:
LOD 0: Full detail — 0-20% screen height → 5000 tris
LOD 1: Medium detail — 20-50% → 2000 tris
LOD 2: Low detail — 50-80% → 500 tris
Culled — 80-100% → not rendered
Setup: Add LODGroup component, assign mesh renderers to each LOD level.
Cross-fade: Enable for smooth transitions (uses dithering). Small GPU cost but looks much better.
LOD Bias: Project Settings > Quality > LOD Bias. Higher = use higher LOD longer. 1.0 = default, 2.0 = double quality distance.
Occlusion Culling
Skip rendering objects hidden behind other objects.
- Mark occluders (walls, buildings) as Occluder Static
- Mark occludees (everything) as Occludee Static
- Bake: Window > Rendering > Occlusion Culling > Bake
- Tune cell size for accuracy vs bake time
When to use: Dense indoor environments, urban areas with buildings. Less useful for open worlds with few occluders.
Frustum culling is free and automatic — only objects in the camera's view are rendered. Occlusion culling is additional.
Texture Optimization
| Platform | Recommended Format | Notes |
|---|
| Desktop | BC7 (quality) / DXT5 (performance) | BC7 is higher quality at same size |
| Mobile (Android) | ASTC 6x6 (quality) / ETC2 (compatibility) | ASTC preferred for modern devices |
| Mobile (iOS) | ASTC 6x6 | Standard for iOS |
| WebGL | DXT5 / ETC2 | DXT for desktop browsers, ETC2 for mobile |
Texture Settings
- Max Size: Match actual usage. A texture shown as 256px on screen does not need 4096px.
- Mipmaps: Enable for 3D objects (reduces aliasing and improves cache performance). Disable for UI sprites.
- Read/Write Enabled: OFF unless you need CPU access. Doubles memory.
- Generate Mipmaps > Streaming: Enable for large worlds. Loads mip levels on demand.
Mesh Optimization
- Polygon budgets: Set per-project. e.g., hero character 10K-50K tris, environment props 100-2K tris
- Mesh Compression: Low/Medium/High in import settings. Reduces disk/download size.
- Read/Write Enabled: OFF unless modifying mesh at runtime. Halves mesh memory.
- Optimize Mesh Data: Enable in Player Settings. Strips unused vertex attributes.
- Vertex Compression: Enable in Player Settings. Uses half-precision where possible.
Quick Wins Checklist
Topic Pages