unity-xr
XR Interaction Toolkit (XRI) skills for VR/AR development. Use when users want to set up XR rigs, add grab/socket/ray interactors, attach grab interactables, configure teleportation, continuous locomotion, snap/smooth turn, XR-aware Canvas/EventSystem, haptics, InteractionLayerMask, or diagnose XR scenes. Triggers: XR, XRI, XR Interaction Toolkit, VR, AR, XR Origin, XR Rig, XRRayInteractor, XRDirectInteractor, XRSocketInteractor, XRGrabInteractable, XRSimpleInteractable, TeleportationProvider, TeleportationArea, TeleportationAnchor, ContinuousMoveProvider, SnapTurnProvider, ContinuousTurnProvider, XRUIInputModule, TrackedPoseDriver, grab, teleport, hand tracking, controller, interactor, interactable, locomotion, haptics, InteractionLayerMask, 抓取, 传送, 手柄, 头盔, 虚拟现实, 增强现实, XR 交互, XR 设置. Requires com.unity.xr.interaction.toolkit; reflection-based bridge supports XRI 2.x (Unity 2022) and XRI 3.x (Unity 6+). Missing-package calls return a diagnostic stub.
- License 许可
- MIT
- 最近更新
- 2026-07-25
- Stars
- ★ 8
- Forks
- 0
01 前言 Front Matter
- name
- unity-xr
- metadata
- { "tier": 2, "source": "https://github.com/Besty0728/Unity-Skills", "version": "1.9.2" }
- use-when
- Load when the task requires: XR Interaction Toolkit (XRI) skills for VR/AR development. Use when users want to set up XR rigs, add grab/socket/ray interactors, attach grab interactables, configure teleportation, continuous locomotion, snap/smooth turn, XR-aware Canvas/EventSystem, haptics, InteractionLayerMask, or diagnose XR scenes. Unity Editor must be running with the unity-skills REST server reachable at http://localhost:8090.
- platforms
- [ "unity-editor", "claude-code" ]
- description
- XR Interaction Toolkit (XRI) skills for VR/AR development. Use when users want to set up XR rigs, add grab/socket/ray interactors, attach grab interactables, configure teleportation, continuous locomotion, snap/smooth turn, XR-aware Canvas/EventSystem, haptics, InteractionLayerMask, or diagnose XR scenes. Triggers: XR, XRI, XR Interaction Toolkit, VR, AR, XR Origin, XR Rig, XRRayInteractor, XRDirectInteractor, XRSocketInteractor, XRGrabInteractable, XRSimpleInteractable, TeleportationProvider, TeleportationArea, TeleportationAnchor, ContinuousMoveProvider, SnapTurnProvider, ContinuousTurnProvider, XRUIInputModule, TrackedPoseDriver, grab, teleport, hand tracking, controller, interactor, interactable, locomotion, haptics, InteractionLayerMask, 抓取, 传送, 手柄, 头盔, 虚拟现实, 增强现实, XR 交互, XR 设置. Requires com.unity.xr.interaction.toolkit; reflection-based bridge supports XRI 2.x (Unity 2022) and XRI 3.x (Unity 6+). Missing-package calls return a diagnostic stub.
- do-not-use-when
- Do not load when Unity Editor is not running locally. Do not load when unity-skills REST server is unreachable at http://localhost:8090.
- task-categories
- [ "xr", "vr-ar", "editor-automation" ]
02 资源文件 1
- 参考文档API_REFERENCE.md12.9 KB
03 SKILL.md 正文
Unity XR Interaction Toolkit Skills
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.
Guardrails
Operating Mode (v1.9 three-tier):
- Approval (default): query/list/info skills (
xr_check_setup,xr_get_scene_report,xr_list_interactors,xr_list_interactables) run directly. Create/modify skills are FullAuto — onMODE_RESTRICTED, run the grant protocol; a successful/permission/grantexecutes the skill server-side and returns the result in the same response. - Auto / Bypass: SemiAuto and FullAuto run directly.
- This module contains no Delete / PlayMode / Reload /
RiskLevel="high"skills, so nothing is auto-classified as forbidden — every skill is reachable via grant. - When
com.unity.xr.interaction.toolkitis missing, everyxr_*skill returns theNoXRI()install instruction instead of executing. - Reflection-sensitive: property names on XRI components must match XRI 2.x/3.x exactly. A wrong field name on
xr_configure_interactable/xr_configure_haptics/xr_configure_interaction_layersis silently ignored. LoadAPI_REFERENCE.mdbefore issuing detailed property edits.
DO NOT (common hallucinations):
XRHand,XRPlayer,XRTeleporter,GrabInteractor,VRController,XRLocomotion, andXRManagerare not the runtime classes you want hereinteractable.OnGrab()/OnRelease()are not the XRI event model -> useselectEntered/selectExitedcontroller.vibrate()is not the documented route here -> configure haptics throughxr_configure_haptics- Do not assume physics Layer or Tag replaces
InteractionLayerMask - Do not guess component property names. Load
API_REFERENCE.mdbefore setting detailed XR component properties
Correct class names to anchor on:
XRInteractionManagerXROriginXRRayInteractorXRDirectInteractorXRSocketInteractorXRGrabInteractableXRSimpleInteractableTeleportationProviderTeleportationAreaTeleportationAnchorContinuousMoveProviderSnapTurnProviderContinuousTurnProviderTrackedDeviceGraphicRaycasterXRUIInputModuleTrackedPoseDriver
Routing:
- For non-XR Canvas UI creation -> use
ui - For architecture or lifecycle decisions in XR gameplay code -> load advisory modules such as
architecture,patterns,async, orscriptdesign - For exact component property names and full workflow examples -> load
API_REFERENCE.md
Skills
Setup and Diagnostics
| 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 |
Interactors and Interactables
| 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 |
Locomotion and XR UI
| 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 |
Feedback and Filtering
| 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 |
Quick Start
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")
Workflow Summary
Rig Setup
- Run
xr_check_setup. - Create the rig with
xr_setup_rig. - Ensure XR UI input exists with
xr_setup_event_system. - Add at least one interactor per controller.
Grab Setup
- Direct hand grab:
xr_add_direct_interactor+xr_add_grab_interactable - Distance grab:
xr_add_ray_interactor+xr_add_grab_interactable - Socket placement:
xr_add_socket_interactor+ grabbable object
movementType defaults matter:
VelocityTracking: best general-purpose physical grabKinematic: use for handles/tools that should not get stuckInstantaneous: best for precise remote grab
Locomotion Setup
- Teleport:
xr_setup_teleportation+xr_add_ray_interactor+xr_add_teleport_area/xr_add_teleport_anchor - Continuous locomotion:
xr_setup_continuous_move - Turn:
xr_setup_turn_provider
Comfort default: snap turn + moderate move speed (~2.0 m/s).
XR UI
- Convert Canvas with
xr_setup_ui_canvas - Ensure
xr_setup_event_system - Add a ray interactor on the controller that should click UI
Collider Configuration Matrix
This 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:
XRGrabInteractableneeds aRigidbody.- A grabbable collider must not be trigger.
- A direct interactor collider must be trigger.
- Dynamic mesh colliders must be convex.
- Socket colliders should be trigger-only overlap zones.
Version Compatibility
| 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 |
Important Notes
- Scenes should normally have exactly one
XRInteractionManager. - Most locomotion skills assume an
XROriginalready exists. - Package installation or reconfiguration can trigger Domain Reload. Wait before retrying XR calls.
- Use
InteractionLayerMaskfor interactor/interactable filtering. - For custom XR scripts, prefer XRI lifecycle hooks and events over
Update()polling when possible.
Minimal Example
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 Signatures
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.
04 同仓库更多 Skills
dots-update-groups
How to choose the right ECS system group and ordering so per-frame and per-fixed-step work is deterministic and never races its own readers. Covers InitializationSystemGroup / SimulationSystemGroup / PresentationSystemGroup / FixedStepSimulationSystemGroup / VariableRateSimulationSystemGroup, UpdateBefore / UpdateAfter peer ordering, OrderFirst / OrderLast group-boundary placement, RateManager, and the cross-group ordering trap. Use when adding an ISystem, fixing "value visible one frame late" bugs, or coupling simulation to a fixed timestep.
dots-transform-patterns
The Entities 1.x transform model — LocalTransform (writable input) vs LocalToWorld (system-owned matrix), Parent/Child hierarchy, reparenting cost, uniform vs non-uniform scale (PostTransformMatrix), and when to opt out with custom transform systems. Use when designing parent/child hierarchies, runtime reparenting (mount/dismount/socket), or choosing transform components at the Baker boundary.
dots-singleton-patterns
Model cross-system shared configuration and game state as a single-entity component with a strict single-writer contract. Covers RequireForUpdate gating, SystemAPI.GetSingleton / GetSingletonRW / HasSingleton / TryGetSingleton, bake-time vs runtime-created vs ECB-system singletons, the "exactly one entity" runtime invariant, and the single-writer rule. Use when designing frame-stable global config, shared mutable state, or any component intended to exist on exactly one entity.
dots-hybrid-bridge
The one-way bridge between DOTS-owned runtime state and Unity-owned presentation. Covers UnityObjectRef for managed asset refs in components, the DOTS-writes / Unity-reads ownership rule, when to use managed IComponentData vs UnityObjectRef vs CompanionComponent, baker-bridge vs runtime-bridge, and SubScene boundary rules. Use when an entity must reference Unity assets (Mesh, Material, AudioClip, ScriptableObject), a MonoBehaviour view must read entity state, or input/UI must trigger ECS work.
dots-event-driven-ecs
Model one-frame events and external requests in ECS without dual ownership, polling, or persistent state leaks. Covers request-tag pattern with ECB, enableable command components (no structural change), event buffers (IBufferElementData), explicit consumer ownership, one-frame latency rules, and the banned C# event / UnityEvent / static bus anti-patterns. Use when input/UI/network must trigger ECS work, when a one-frame signal fans out to N consumers (damage, hit, collision), or when state changes must be processed exactly once.
valid_skill
A complete, well-formed test fixture skill for SkillHub validation testing. Covers basic task routing and code review for Unity projects.