gamedev-unity/skills/unity-skills/skills/xr/SKILL.md
Set up XR Interaction Toolkit (XRI) for VR/AR — XR rigs and grab/socket/ray interactors. Use when building VR/AR interaction, setting up an XR rig, or configuring grab/socket/ray interactors, even if the user just says "VR" or "XR交互". 搭建用于 VR/AR 的 XR Interaction Toolkit(XRI:XR rig、抓取/插槽/射线交互器);当用户要构建 VR/AR 交互、搭建 XR rig、或配置抓取/插槽/射线交互器时使用。
npx skillsauth add bernatmv/ai-rules unity-xrInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Use this module for XR Interaction Toolkit setup and configuration. All xr_* skills are reflection-based and support XRI 2.x on Unity 2022 and XRI 3.x on Unity 6+.
Requires:
com.unity.xr.interaction.toolkit. Hard rule: Read this file before the firstxr_*call in a session. Wrong property names can fail silently because the bridge is reflection-based.
Operating Mode (v1.9 three-tier):
xr_check_setup, xr_get_scene_report, xr_list_interactors, xr_list_interactables) run directly. Create/modify skills are FullAuto — on MODE_RESTRICTED, run the grant protocol; a successful /permission/grant executes the skill server-side and returns the result in the same response.RiskLevel="high" skills, so nothing is auto-classified as forbidden — every skill is reachable via grant.com.unity.xr.interaction.toolkit is missing, every xr_* skill returns the NoXRI() install instruction instead of executing.xr_configure_interactable / xr_configure_haptics / xr_configure_interaction_layers is silently ignored. Load API_REFERENCE.md before issuing detailed property edits.DO NOT (common hallucinations):
XRHand, XRPlayer, XRTeleporter, GrabInteractor, VRController, XRLocomotion, and XRManager are not the runtime classes you want hereinteractable.OnGrab() / OnRelease() are not the XRI event model -> use selectEntered / selectExitedcontroller.vibrate() is not the documented route here -> configure haptics through xr_configure_hapticsInteractionLayerMaskAPI_REFERENCE.md before setting detailed XR component propertiesCorrect class names to anchor on:
XRInteractionManagerXROriginXRRayInteractorXRDirectInteractorXRSocketInteractorXRGrabInteractableXRSimpleInteractableTeleportationProviderTeleportationAreaTeleportationAnchorContinuousMoveProviderSnapTurnProviderContinuousTurnProviderTrackedDeviceGraphicRaycasterXRUIInputModuleTrackedPoseDriverRouting:
uiarchitecture, patterns, async, or scriptdesignAPI_REFERENCE.md| Skill | Use | Key parameters |
|-------|-----|----------------|
| xr_check_setup | Validate XR package, rig, managers, and scene prerequisites | verbose? |
| xr_setup_rig | Create XR Origin + camera + controllers | name, cameraYOffset? |
| xr_setup_interaction_manager | Add or find manager | none |
| xr_setup_event_system | Replace/add XR UI input stack | none |
| xr_get_scene_report | Report scene-side XR status | none |
| Skill | Use | Key parameters |
|-------|-----|----------------|
| xr_add_ray_interactor | Remote pointing / ray interaction | name, maxDistance?, lineType? |
| xr_add_direct_interactor | Close-range hand grab | name, radius? |
| xr_add_socket_interactor | Snap-to slot | name, showHoverMesh?, recycleDelay? |
| xr_add_grab_interactable | Rigidbody + collider + grab config | name, movementType?, throwOnDetach? |
| xr_add_simple_interactable | Hover/select without grab | name |
| xr_configure_interactable | Fine-tune interactable behavior | target + changed fields only |
| xr_list_interactors | List all scene interactors | none |
| xr_list_interactables | List all scene interactables | none |
| Skill | Use | Key parameters |
|-------|-----|----------------|
| xr_setup_teleportation | Add teleport provider to XR Origin | none |
| xr_add_teleport_area | Mark a surface as teleportable | name, matchOrientation? |
| xr_add_teleport_anchor | Create fixed teleport destination | name, x/y/z, rotY?, matchOrientation? |
| xr_setup_continuous_move | Add stick locomotion | moveSpeed?, enableStrafe?, enableFly? |
| xr_setup_turn_provider | Add snap or smooth turn | turnType, turnAmount?, turnSpeed? |
| xr_setup_ui_canvas | Convert Canvas for XR interaction | name |
| Skill | Use | Key parameters |
|-------|-----|----------------|
| xr_configure_haptics | Set hover/select vibration | name, intensities, durations |
| xr_add_interaction_event | Wire interaction callback to target method | name, eventType, targetName, targetMethod |
| xr_configure_interaction_layers | Set InteractionLayerMask | name, layers, isInteractor |
import unity_skills as u
u.call_skill("xr_check_setup")
u.call_skill("xr_setup_rig", name="XR Origin")
u.call_skill("xr_add_ray_interactor", name="Right Controller")
u.call_skill("xr_add_direct_interactor", name="Left Controller")
u.call_skill("xr_setup_teleportation")
u.call_skill("xr_setup_turn_provider", turnType="Snap", turnAmount=45)
u.call_skill("xr_add_grab_interactable", name="MyCube", movementType="VelocityTracking")
xr_check_setup.xr_setup_rig.xr_setup_event_system.xr_add_direct_interactor + xr_add_grab_interactablexr_add_ray_interactor + xr_add_grab_interactablexr_add_socket_interactor + grabbable objectmovementType defaults matter:
VelocityTracking: best general-purpose physical grabKinematic: use for handles/tools that should not get stuckInstantaneous: best for precise remote grabxr_setup_teleportation + xr_add_ray_interactor + xr_add_teleport_area/xr_add_teleport_anchorxr_setup_continuous_movexr_setup_turn_providerComfort default: snap turn + moderate move speed (~2.0 m/s).
xr_setup_ui_canvasxr_setup_event_systemThis is the most important XR anti-hallucination table in the repo.
| Component | Collider required | isTrigger | Recommended collider | Reason |
|----------|-------------------|-------------|----------------------|--------|
| XRDirectInteractor | Yes | True | SphereCollider (0.1-0.25) | Overlap detection |
| XRRayInteractor | No | - | None | Uses raycasts |
| XRSocketInteractor | Yes | True | SphereCollider (0.1-0.3) | Snap zone |
| XRGrabInteractable | Yes | False | BoxCollider or convex MeshCollider | Physics + ray target |
| XRSimpleInteractable | Yes | False | BoxCollider | Selection detection |
| TeleportationArea | Yes | False | MeshCollider or BoxCollider | Surface raycast target |
| TeleportationAnchor | Yes | False | Thin BoxCollider | Point raycast target |
Critical rules:
XRGrabInteractable needs a Rigidbody.| Topic | XRI 2.x | XRI 3.x |
|------|---------|---------|
| Main namespace style | root namespace | split sub-namespaces |
| Rig type | XROrigin | XROrigin |
| Locomotion core | LocomotionSystem | LocomotionMediator |
| Controller type | ActionBasedController | ActionBasedController |
| Bridge behavior | Reflection helper falls back automatically | Reflection helper prefers 3.x first |
XRInteractionManager.XROrigin already exists.InteractionLayerMask for interactor/interactable filtering.Update() polling when possible.import unity_skills as u
u.call_skill("xr_setup_rig", name="XR Origin", cameraYOffset=1.36)
u.call_skill("xr_setup_event_system")
u.call_skill("xr_add_ray_interactor", name="Right Controller", maxDistance=30, lineType="StraightLine")
u.call_skill("xr_add_grab_interactable", name="Tool", movementType="VelocityTracking", throwOnDetach=True)
u.call_skill("xr_configure_haptics", name="Right Controller", selectIntensity=0.7, selectDuration=0.15)
Exact names, parameters, defaults, and returns are defined by GET /skills/schema or unity_skills.get_skill_schema(), not by this file.
Before configuring XR component properties in detail, load API_REFERENCE.md. XR property names are reflection-sensitive.
development
Keyword research and validation with real search-demand data — never ship keywords from intuition alone. Probes Google Autocomplete per language (free, no account) to prove demand and discover the exact phrasing people type, checks SERPs for winnability, and uses Keyword Planner/Ahrefs/Semrush exports when the user has access. Activates when: choosing or reviewing SEO keywords, meta keywords, page titles, article topics or slugs, landing page copy targeting search, App Store/ASO keyword fields, multilingual keyword sets, 'what should we rank for', 'keyword analysis', or auditing why a page doesn't rank. Also invoke it as a validation pass whenever another skill or task produces a keyword list.
development
Automate YooAsset hot-update and asset bundles — build bundles, run Editor simulate builds, manage Collector groups, analyze BuildReport, and validate runtime. Use when building or simulating YooAsset bundles, configuring collectors, or validating hot-update assets, even if the user just says "热更" or "打AB包". 自动化 YooAsset 热更新与资源包(构建 bundle、编辑器模拟构建、管理 Collector 分组、分析 BuildReport、运行时校验);当用户要构建或模拟 YooAsset 资源包、配置 collector、或校验热更资源时使用。
development
Source-anchored design rules for YooAsset v2.3.18 — initialization, default-package shortcuts, play modes, asset handles, loading, updates, filesystem, build, and pitfalls. Use when writing or reviewing YooAsset code, initializing packages, loading assets via handles, setting up hot-update/download, or choosing a play mode, even if the user just says "热更" or "资源包". 为 YooAsset v2.3.18 提供源码锚定的设计规则(初始化、默认包快捷方式、运行模式、资源句柄、加载、更新、文件系统、构建、陷阱);当用户要编写或审查 YooAsset 代码、初始化 package、用句柄加载资源、配置热更/下载、或选择运行模式时使用。
data-ai
Last-resort guidance for safely hand-editing Unity serialized YAML (.unity/.prefab/.asset/.meta/ProjectSettings) — reference/fileID repair, GUID safety, and merge-conflict fixes. Use when REST cannot reach the change and YAML must be hand-edited — fixing m_Script GUIDs, broken fileID references, .meta files, or merge conflicts, even if the user just says "场景文件打不开" or "引用丢了". 安全手编 Unity 序列化 YAML(.unity/.prefab/.asset/.meta/ProjectSettings)的最后手段(引用/fileID 修复、GUID 安全、合并冲突修复);当 REST 无法触达、必须手编 YAML 时使用——修复 m_Script GUID、断裂 fileID 引用、.meta 文件或合并冲突。