/unity-master:unity-performancefrom unity-master
Optimizes Unity game performance: profiling workflow, batching, object pooling, GC reduction, LOD/culling, and texture compression. Activates for slow games, stutters, FPS drops, and build size reduction.
Ships in unity-master. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Systematic approach to profiling and optimizing Unity games. Covers profiling tools, CPU/GPU optimization, memory management, rendering optimization, and platform-specific considerations.
| 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 |
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).
| 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 |
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.
| 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) |
| 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 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.
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.
| Issue | Solution |
|---|---|
| Complex fragment shaders | Reduce texture samples, simplify math |
| Overdraw | Minimize transparent objects, use opaque when possible |
| Too many variants | Strip unused shader variants in build settings |
| Expensive post-processing | Disable effects on mobile, use cheaper alternatives |
| Issue | Symptom | Fix |
|---|---|---|
| Texture bloat | High memory, long loads | Compress textures, reduce max size per platform |
| Unloaded scenes holding refs | Memory climbs over time | Use Resources.UnloadUnusedAssets() after scene transitions |
| Addressables not released | Bundles stay in memory | Call Addressables.Release(handle) |
| Audio clips uncompressed | Huge memory footprint | Use compressed in memory for music, decompress on load for SFX |
| Mesh read/write enabled | Double memory per mesh | Disable Read/Write if not needed at runtime |
| Platform | Format | Notes |
|---|---|---|
| PC/Console | BC7 (DXT) | Best quality/size ratio |
| Android | ASTC 6x6 | Universal, scalable quality |
| iOS | ASTC 6x6 | Same as Android |
| WebGL | ETC2 / DXT | Depends on target GPU |
Use "Override for [Platform]" in texture import settings. Set max texture size to the minimum needed (512 for UI icons, 1024 for props, 2048 for hero assets).
| Platform | Key Constraints |
|---|---|
| Mobile | Thermal throttling, limited memory, battery drain, fill-rate limited |
| WebGL | No threads (pre-Unity 6), large download size, no compute shaders |
| Console | Certification requirements, fixed hardware, memory budgets |
| VR/XR | 72-90 FPS minimum, stereo rendering cost, motion sickness from drops |
Use Addressables for async asset loading to avoid load-time hitches:
// Preload during loading screen
var handle = Addressables.LoadAssetAsync<GameObject>("enemy_boss");
await handle;
// Release when done
Addressables.Release(handle);
Use Addressable groups to control bundle granularity. Mark infrequently used assets as remote/on-demand. Profile bundle memory with the Addressables Event Viewer.
references/profiling-deep-dive.md -- Advanced Profiler usage, memory profiler snapshots, frame-by-frame analysis, custom profiler markers, automated performance testing, build size analysis, ECS/DOTS performance patternsWhat SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
7 skills in this plugin
/unity-csharp-scriptingC# scripting in Unity for gameplay, behavior, and engine integration.
PROACTIVELY activate for: (1) writing Unity C# scripts, (2) MonoBehaviour lifecycle (Awake/OnEnable/Start/Update/FixedUpdate/LateUpdate), (3) coroutines and async/await in Unity, (4) delegates, events, Action/Func patterns, (5) ScriptableObject creation and serialization, (6) GetComponent / TryGetComponent and component caching, (7) physics scripting (Rigidbody, raycast, collision/trigger callbacks), (8) animation scripting (Animator parameters, state machines, IK), (9) NavMesh and NavMeshAgent scripting, (10) input handling (Input System package), (11) custom serialization and SerializeField.
Provides: lifecycle reference, coroutine vs async patterns, ScriptableObject templates, Rigidbody/collision recipes, NavMesh examples, and Input System setup.
/unity-editor-toolingUnity Editor tooling, build automation, and asset pipeline customization.
PROACTIVELY activate for: (1) writing custom Editor scripts, (2) custom inspectors and PropertyDrawer attributes, (3) EditorWindow creation, (4) ScriptedImporter for custom asset types, (5) build pipeline scripting (BuildPipeline.BuildPlayer, IBuildPostprocessor), (6) platform-switching automation, (7) CI/CD for Unity (GameCI, GitHub Actions, Unity Build Automation), (8) Assembly Definition (.asmdef) organization, (9) preprocessor symbols and platform defines, (10) Editor-only code with #if UNITY_EDITOR.
Provides: custom inspector templates, EditorWindow examples, build script patterns, GameCI setup, .asmdef best practices, and CI YAML for Unity builds.
/unity-moddingUnity game modding architecture and mod-loading systems.
PROACTIVELY activate for: (1) adding modding support to a Unity game, (2) Asset Bundles for mods, (3) Addressables for mod content, (4) Lua scripting via MoonSharp, (5) Harmony patching for runtime IL injection, (6) Steam Workshop integration, (7) mod manager UI, (8) plugin architecture for user-generated content (UGC), (9) custom content loading at runtime, (10) sandboxing and security for untrusted mods.
Provides: AssetBundle vs Addressables tradeoffs, MoonSharp setup, Harmony patch patterns, Steam Workshop SDK integration, mod manager templates, and security guidelines.
/unity-networkingUnity multiplayer networking with NGO, Mirror, Photon, and Fish-Net.
PROACTIVELY activate for: (1) building Unity multiplayer games, (2) Netcode for GameObjects (NGO) setup and patterns, (3) Mirror networking, (4) Photon PUN and Photon Fusion, (5) Fish-Net networking, (6) RPCs (ClientRpc, ServerRpc), (7) NetworkVariable and network synchronization, (8) lobby and matchmaking systems, (9) dedicated server hosting and Relay, (10) server-authoritative architecture, (11) lag compensation and prediction.
Provides: networking-stack comparison, NGO templates, RPC patterns, NetworkVariable usage, lobby/matchmaking setup, and authoritative-server design.
/unity-shaders-renderingUnity shaders, materials, and rendering pipelines (URP/HDRP/Built-in).
PROACTIVELY activate for: (1) writing shaders in Shader Graph, HLSL, or ShaderLab, (2) URP and HDRP shader authoring, (3) custom render pipeline work (SRP), (4) lighting setup (baked vs realtime, lightmaps, Global Illumination), (5) post-processing stacks, (6) reflection probes and light probes, (7) custom render features and full-screen passes, (8) shader stripping and variant management, (9) compute shaders, (10) ray tracing in HDRP.
Provides: Shader Graph templates, HLSL snippets, URP/HDRP differences, lighting setup recipes, render-feature examples, and shader-variant guidance.
/unity-ui-developmentUnity UI development with UGUI and UI Toolkit.
PROACTIVELY activate for: (1) building Unity user interfaces, (2) UGUI (Canvas, RectTransform, anchors), (3) UI Toolkit (USS, UXML, VisualElement), (4) EventSystem and input handling, (5) common UI components (buttons, scroll views, dropdowns), (6) inventory UIs, HUDs, health bars, menu systems, (7) TextMeshPro setup and rich text, (8) responsive UI (anchors, layout groups), (9) runtime UI generation, (10) world-space canvases for in-game UI.
Provides: UGUI vs UI Toolkit comparison, RectTransform patterns, USS/UXML examples, layout group recipes, and TextMeshPro templates.
npx claudepluginhub josiahsiegel/claude-plugin-marketplace --plugin unity-masterOther plugins' skills for the same job