hz-unity-code-review
安装方式
先用 Prompt 核对来源与依赖。也可下载安装包。
用 AI 助手安装
复制提示词,让助手先核对固定版本和依赖。
查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "hz-unity-code-review":https://skillpi.com/zh/skills/deepskill-221aef17a630b38e880c3ab5e19c7f2f656b3a8ca0c2d43778dca21e4efd7750。安装前核对上游来源和版本:https://github.com/meta-quest/agentic-tools。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。
来源与配置
github.com
配置方式待核实
请查看原始来源中的适用工具、依赖和权限要求。
安装实测待补充
审查面向 Meta Quest 与 Horizon OS 的 Unity 代码,重点关注性能问题、渲染最佳实践和常见的 VR 陷阱。适用于代码审查阶段或诊断 Unity 项目中 Quest 性能问题时参考使用。
介绍来源: third_party · meta-quest · 0.0.1 参考来源
SkillPi 解读
- 能完成的任务
- 翻译待完成,请参阅来源文档。
- 适合谁
- 翻译待完成,请参阅来源文档。
- 输入和输出
- 翻译待完成,请参阅来源文档。
- 软件、账号及付费要求
- 翻译待完成,请参阅来源文档。
- 实测状态
- 未测试
文件浏览
Frontmatter
name: hz-unity-code-review
license: Apache-2.0
description: Reviews Unity code targeting Meta VR and Horizon OS for performance issues, rendering best practices, and common VR pitfalls. Use during code review or when diagnosing Meta VR performance problems in Unity projects.
allowed-tools: Bash(metavr:*), Bash(hzdb:*)Unity Code Review for Meta VR
When to Use
Use this skill when reviewing Unity C# code or project settings that target Meta VR headsets. This includes:
- Reviewing scripts for VR performance issues
- Checking rendering pipeline configuration and settings
- Ensuring adherence to Meta VR-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
Meta VR 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 Meta VR 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
Meta VR 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 | Meta VR Glasses |
|---|---|---|---|
| Draw calls (busy simulation) | 80-200 | 200-300 | 200-300 |
| Draw calls (medium simulation) | 200-300 | 400-600 | 400-600 |
| Draw calls (light simulation) | 400-600 | 700-1000 | 700-1000 |
| Triangles per frame | 750K-1M | 1M-2M | 1M-2M |
| SetPass calls | < 50 | < 80 | < 80 |
Enable and verify:
- Static batching for non-moving geometry
- GPU instancing for repeated objects
- SRP batcher for URP materials
- Dynamic batching for small meshes (< 300 vertices)
3. Shader Complexity
Mobile GPUs on Meta VR cannot handle desktop-class shaders. Review all materials for:
- Use of URP/Lit or URP/Simple Lit instead of Standard shader
- Custom shaders that minimize texture samples and ALU operations
- Avoidance of real-time shadows where possible (bake instead)
- No screen-space effects (SSAO, SSR, screen-space shadows)
4. Memory Management
GC allocations cause frame hitches and must be eliminated from hot paths.
// BAD: Allocates every frame
void Update() {
string label = "Score: " + score.ToString();
var enemies = FindObjectsOfType<Enemy>();
var filtered = enemies.Where(e => e.IsAlive).ToList();
}
// GOOD: Zero allocations in Update
private StringBuilder _sb = new StringBuilder(32);
private List<Enemy> _enemyCache = new List<Enemy>();
private Enemy[] _enemyArray;
void Start() {
_enemyArray = FindObjectsOfType<Enemy>();
}
void Update() {
_sb.Clear();
_sb.Append("Score: ");
_sb.Append(score);
}
5. Input Handling
Meta VR supports multiple input modalities. Code should handle:
- Controllers: Use Unity's Input System Package for new projects (recommended);
OVRInputis maintained for legacy support - Hand tracking:
OVRHandandOVRSkeletonfor hand pose data - Eye tracking:
OVREyeGaze(Quest Pro / Meta VR Glasses, 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 < 16)
- Spatialize audio using Meta's audio SDK for 3D positioning
Quick Review Checklist
| Area | Target | Notes |
|---|---|---|
| Draw calls | 80-200 (busy) to 400-600 (light) | Use batching, instancing, atlasing |
| Triangles | 750K-1M/frame | Use LODs, occlusion culling |
| Texture resolution | Max 2K, 4K sparingly | ASTC compression required |
| Shader | URP mobile shaders | No Standard shader, no screen-space effects |
| Rendering mode | Single-pass multiview | Must be enabled in XR settings |
| FFR | Enabled (High or HighTop) | Fixed foveated rendering reduces edge fragment cost |
| MSAA | 4x quality / 2x perf | Free on tile-based GPU when configured correctly |
| Target frame rate | 72 Hz minimum | 90 Hz recommended, 120 Hz for smooth experiences |
| GC allocations | 0 B/frame in steady state | No allocations in Update/LateUpdate/FixedUpdate |
| Audio sources | < 16 simultaneous | Use pooling for audio sources |
What to Look For in Code
GC-Heavy Patterns
// Flag these patterns in code review:
Camera.main // Calls FindWithTag internally
GameObject.Find("name") // Linear search every call
GetComponent<T>() in Update // Cache the result
new List<T>() 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
// 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
// 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
// BAD: Expensive search every frame
void Update() {
var player = GameObject.FindWithTag("Player");
var rb = player.GetComponent<Rigidbody>();
}
// GOOD: Cache in Awake/Start or use dependency injection
private Rigidbody _playerRb;
void Awake() {
_playerRb = GameObject.FindWithTag("Player").GetComponent<Rigidbody>();
}
Using metavr for Validation
You can use the metavr tool to validate builds and check device-side behavior. Invoke via metavr <args> (published as the npm package metavr; if metavr is not on PATH, run npx -y metavr <args>) — no install required.
# Check connected Meta VR 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 — comprehensive performance targets and optimization strategies
- Rendering Best Practices — Meta VR-specific rendering configuration and shader guidelines
- Input Handling — controller, hand tracking, and eye tracking implementation
- Common Pitfalls — frequently encountered mistakes and their fixes
版本历史
-
v1.8.0
GitHub ↗
原版更新说明
**Full Changelog**: https://github.com/meta-quest/agentic-tools/compare/v1.2.3...v1.8.0
-
v1.2.3
GitHub ↗
原版更新说明
**Full Changelog**: https://github.com/meta-quest/agentic-tools/compare/v1.2.1...v1.2.3
-
v1.2.1
GitHub ↗
原版更新说明
**Full Changelog**: https://github.com/meta-quest/agentic-tools/commits/v1.2.1
当前收录版本
0.0.1
安全与评测信息
质量评测
满分100 · 来自 SkillPi LAB 实验室的评测报告。
亮点
- 针对 Meta Quest/Horizon OS 的 Unity 开发提供具体性能审查指南
- 包含详细的性能指标表格和代码优化模式对比
亮点
- 触发词精准覆盖 Unity VR 开发场景
- description 完整且位置正确
亮点
- 结构清晰,分模块组织审查要点
- 提供端到端代码示例和检查清单
亮点
- 工具调用参数正确且来源明确
- 覆盖主要性能陷阱和异常处理
取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。
正文静态检测
100 / 100 · skillpi-20261123-no-r3-v1
正文未命中当前规则。
分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。
权限与使用前检查
根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。
-
安装或获取外部依赖
使用官方来源并锁定版本,在隔离环境检查安装脚本。当前文档检查不覆盖后续下载的代码。
主文档提及 · 第 206 行
安全评级与访问范围
safe · 静态证据核验,不代表运行安全保证。
翻译待完成,请参阅来源文档。
使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。
用户讨论
还没有已核实的点评。