# Hz Unity Code Review

> Reviews Unity code targeting Meta Quest and Horizon OS for performance issues, rendering best practices, and common VR pitfalls. Use during code review or when diagnosing Quest performance problems in Unity projects.

- **Type:** Skill
- **Install:** `agentstack add skill-meta-quest-agentic-tools-hz-unity-code-review`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [meta-quest](https://agentstack.voostack.com/s/meta-quest)
- **Installs:** 0
- **Category:** [Agent Skills](https://agentstack.voostack.com/c/agent-skills)
- **Latest version:** 0.1.0
- **License:** Apache-2.0
- **Upstream author:** [meta-quest](https://github.com/meta-quest)
- **Source:** https://github.com/meta-quest/agentic-tools/tree/main/skills/hz-unity-code-review
- **Website:** https://developers.meta.com/horizon

## Install

```sh
agentstack add skill-meta-quest-agentic-tools-hz-unity-code-review
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# Unity Code Review for Meta Quest

## When to Use

Use this skill when reviewing Unity C# code or project settings that target Meta Quest headsets. This includes:

- Reviewing scripts for VR performance issues
- Checking rendering pipeline configuration and settings
- Ensuring adherence to Quest-specific best practices
- Identifying common VR development pitfalls
- Validating input handling for controllers, hands, and eye tracking
- Auditing memory usage and GC allocation patterns

## Key Review Areas

### 1. Rendering Pipeline Configuration

Quest applications must use the Universal Render Pipeline (URP) with specific settings optimized for mobile VR. The Built-in Render Pipeline is not recommended for new Quest projects.

Critical settings to verify:

- **Single-pass multiview** must be enabled (Player Settings > XR Plug-in Management > Oculus > Stereo Rendering Mode)
- **Vulkan** should be the primary graphics API
- **Linear color space** is required for correct lighting
- **HDR** should be disabled in URP asset settings
- **Post-processing** should be minimal or disabled

### 2. Draw Call Budgets and Batching

Quest has draw call budgets that vary by workload complexity. Every draw call has CPU overhead that directly impacts frame timing.

| Metric | Quest 2 / Quest Pro | Quest 3 / Quest 3S |
|--------|---------------------|---------------------|
| Draw calls (busy simulation) | 80-200 | 200-300 |
| Draw calls (medium simulation) | 200-300 | 400-600 |
| Draw calls (light simulation) | 400-600 | 700-1000 |
| Triangles per frame | 750K-1M | 1M-2M |
| SetPass calls | ();
    var filtered = enemies.Where(e => e.IsAlive).ToList();
}

// GOOD: Zero allocations in Update
private StringBuilder _sb = new StringBuilder(32);
private List _enemyCache = new List();
private Enemy[] _enemyArray;

void Start() {
    _enemyArray = FindObjectsOfType();
}

void Update() {
    _sb.Clear();
    _sb.Append("Score: ");
    _sb.Append(score);
}
```

### 5. Input Handling

Quest supports multiple input modalities. Code should handle:

- **Controllers**: Use Unity's Input System Package for new projects (recommended); `OVRInput` is maintained for legacy support
- **Hand tracking**: `OVRHand` and `OVRSkeleton` for hand pose data
- **Eye tracking**: `OVREyeGaze` (Quest Pro / Quest 3, requires permission)
- **Graceful switching** between controller and hand tracking modes

### 6. Physics Configuration

Physics simulation is expensive on mobile. Review for:

- Physics timestep set to match target frame rate (72/90/120 Hz)
- Simplified collision meshes (use primitives, not mesh colliders)
- Reduced solver iterations (4-6 is usually sufficient)
- Layer-based collision matrix to minimize pair checks
- Rigidbody sleep thresholds configured appropriately

### 7. Audio Setup

Audio is often overlooked but can impact performance:

- Compress audio clips (Vorbis for music, ADPCM for short SFX)
- Use streaming load type for clips longer than 1 second
- Limit simultaneous audio sources (target () in Update         // Cache the result
new List() in Update             // Allocates on heap
string + string in Update           // Creates new string objects
foreach on non-List collections     // Enumerator allocation
LINQ queries (.Where, .Select)      // Multiple allocations
Boxing (int -> object)              // Heap allocation
delegate/lambda in hot paths        // Closure allocation
```

### Update() Misuse

```csharp
// BAD: Empty Update still has overhead
void Update() { }

// BAD: Logic that doesn't need per-frame execution
void Update() {
    SavePlayerPrefs();  // Should be event-driven
}

// GOOD: Use events, coroutines, or InvokeRepeating for non-per-frame logic
void OnScoreChanged(int newScore) {
    UpdateScoreUI(newScore);
}
```

### Camera.main Anti-Pattern

```csharp
// BAD: Camera.main uses FindWithTag internally
void Update() {
    transform.LookAt(Camera.main.transform);
}

// GOOD: Cache the reference
private Transform _cameraTransform;

void Start() {
    _cameraTransform = Camera.main.transform;
}

void Update() {
    transform.LookAt(_cameraTransform);
}
```

### Find Calls in Hot Paths

```csharp
// BAD: Expensive search every frame
void Update() {
    var player = GameObject.FindWithTag("Player");
    var rb = player.GetComponent();
}

// GOOD: Cache in Awake/Start or use dependency injection
private Rigidbody _playerRb;

void Awake() {
    _playerRb = GameObject.FindWithTag("Player").GetComponent();
}
```

## Using metavr for Validation

You can use the `metavr` tool to validate builds and check device-side behavior. Invoke via `metavr ` (published as the npm package `metavr`; if `metavr` is not on PATH, run `npx -y metavr `) — no install required.

```bash
# Check connected Quest device
metavr device list

# Install and run a build
metavr app install path/to/build.apk
metavr app launch com.company.app

# Check device logs for errors
metavr adb logcat --tag Unity

# Monitor GPU performance
metavr perf capture
```

Use device-side profiling to validate that code review findings translate to real performance improvements.

## Reference Documents

For detailed guidance on specific topics, see the following reference documents:

- [Performance Checklist](references/performance-checklist.md) — comprehensive performance targets and optimization strategies
- [Rendering Best Practices](references/rendering-best-practices.md) — Quest-specific rendering configuration and shader guidelines
- [Input Handling](references/input-handling.md) — controller, hand tracking, and eye tracking implementation
- [Common Pitfalls](references/common-pitfalls.md) — frequently encountered mistakes and their fixes

## Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [meta-quest](https://github.com/meta-quest)
- **Source:** [meta-quest/agentic-tools](https://github.com/meta-quest/agentic-tools)
- **License:** Apache-2.0
- **Homepage:** https://developers.meta.com/horizon

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** no
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/skill-meta-quest-agentic-tools-hz-unity-code-review
- Seller: https://agentstack.voostack.com/s/meta-quest
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
