visionOS helpers
This module provides some components to help building vision OS application with Unity's Polyspatial, and make them cross-platform. It relies notably on XRShared's XRHands synchronization, to provide proper hand tracking synchronization and gesture detection in Polyspatial unbounded mode.
Spatial Touch
The vision OS platform provides specific gestures to interact with objects having a collider: touch, pinch, indirect pinch.
Unity's Polyspatial exposes those moves, and the addon's SpatialTouchHandler class detects those interactions.
If a SpatialTouchHandler is in the scene, and an object interacted with as a component implementing ISpatialTouchListener, it will receive associated callbacks.
Grabbing with spatial touch
To be able to grab using the same components than used in the XRShared addon, the SpatialGrabber and HardwareSpatialPointer components (in the SpatialTouch prefab), with their network counterpart NetworkSpatialPointer (in the NetworkSpatialGrabber prefab), allow to have an additional "hand", not tied to an HardwareHand/NetworkHand pair.
The SpatialTouch prefab must be placed as a child of the hardware rig (in the demo scene, it is a child of the AVPHardwareRig), and the NetworkSpatialGrabber prefab inside the user network rig prefab (as in the NetworkRigWithVoiceSpatialGrabber prefab): at the root of the scene, they are not found and no spatial grabbing occurs.
It is available in both the unbounded volume mode, to be able to grab from distance, and in the bounded mode, where regular hands are not present anyway.
Regarding "regular" grabs, that is when the hand are placed on the object, it is possible to either use the hardware rig grabbers, which use the hands position, or the visionOS spatial grabber. On the SpatialTouchHandler component, the replaceContactGrabber option allows to choose between the 2 options :
- if
replaceContactGrabberis set totrue(default), the grabbed object movement will be smoother: on visionOS, the hand bones are refreshed less frequently than the spatial touch position, so objects will jitter if they use the hands movements as a reference - if
replaceContactGrabberis set tofalse, the grabbed object will stay in sync with the hands, otherwise, there is a little position difference, as the grabbed object movement is not based on the actual hand position, but on the spatial touch API results. It can be relevant if the hand models are displayed.
Volume mode synchronization
For application handling both bounded and unbounded volume mode, it is important to warn remote user of the mode selected, for instance to make the avatar vanish while in bounded mode.
To do so easily, the VisionOsVolumeCameraModeSync synchronize the mode of the local user, if placed on their network rig.
It also allows to easily hide all user renderers automatically while in bounded mode, with the hideAllChildRenderersInBoundedVolume option.
Volume mode change handling
The VolumeCameraConfigurationSelector class also offer a convenient way to change volume mode: enabling an object with this component will automatically change the Polyspatial's VolumeCamera volume configuration with volumeConfiguration, if it is not already the same.
In addition, it can activate/desactivate some game objects, allowing to easily have volume mode specific game objects.
Cross-platform components
Aside from the grabbing behavior enhanced to support spatial grabbing, and the XR Hands, some tools help in building cross-platform experiences.
Touch
SpatialTouchable implements both ISpatialTouchListener and ITouchable, to react both to spatial touch, and to regular touch, working on all platforms.
SpatialButton is an enhanced version of SpatialTouchable, that can be used as a toggle button or a radio button.
UI
To have the similar behavior of a visionOS Window on all platform, the ConstrainedGrabbable class can be used to move grabbable windows in a similar way the windows are moved on visionOS (they "look" at the user while being grabbed, ensuring a proper positioning).
LineMesh
The LineRenderer component is currently not compatible with Polyspatial. the included LineMesh component offers a simple alternative, that creates a mesh.
The stored Point include a color property that will affect the mesh vertex colors. A sample shader, LineSG, compatible with Polyspatial, uses those vertex color info to render the mesh.
If some component relies on LineRenderers, the LineRendererToLineMesh offers a way to automatically feed a LineMesh with the line renderer info.
Automatic hand configuration
If the hands from XRShared's XRHands synchronization are used, the VisionOSHandsConfiguration allows a quick automatic configuration of the hands for the Polyspatial vision OS platform.
The script:
- uses
LineMeshto display the beam used by aRayBeamercomponent - applies a specific layer to all collider in hands, that should be removed from Polyspatial handled colliders, to be sure that the grabbing/touching collider are not spatial touched by visionOS (which is probably not desired)
Rig teleportation
In unbounded volume applications, if the user rig should teleports, then on visionOS the VolumeCamera should move accordingly, to change the zero of the camera space.
The VolumeCameraLocomotion, that should be placed on the same game object than the VolumeCamera handles this automatically. during each LateUpdate:
- it ensures that the
VolumeCamerapositions matches theHardwareRigposition (the one we usually teleport) - it also does the same for any
ARPlaneManagerthat could be present in the scene, as ARFundation has the same requirement for teleportation
Dependencies

- XRShared
- VoiceHelpers
- ConnectionManager
- Unity XR Hands
- Unity PolySpatial packages (for visionOS builds):
com.unity.polyspatial,com.unity.polyspatial.visionosandcom.unity.polyspatial.xr
On Unity 6, building for another platform (Android for instance) fails while the PolySpatial packages are installed: remove them before building a non-visionOS version of a cross-platform project.
Download
This addon latest version is included into the XR Addons project
Supported topologies
- shared mode
Changelog
- Version 2.1.1: Add FUSION_WEAVER to VisionOsHelpers.Editor asmdef define constraints (no compile error before Fusion is installed)
- Version 2.1.0: Update to support new XRShared architecture
- Version 2.0.10: Add Polyspatial packages verification because of compatibility issue with Unity 6 when building for Android
- Version 2.0.9:
- Material parameter update for Unity 6
- Use FindAnyObjectByType, FindObjectsByType, SetScriptingDefineSymbols & GetScriptingDefineSymbols to remove warnings
- Version 2.0.8: Fix for Polyspatial 2 on Unity 6
- Version 2.0.7: Fix - SkinnedMeshRenderer needs animator culling mode to be set to always animate on visionOs
- Version 2.0.6:
- Add VolumeCameraLocomotion to follow HardwareRig movements
- Add a SpatialPointerState parameter to ISpatialTouchListener (breaking change)
- Version 2.0.5:
- Add preventGrabbingSpatialTouchListeners option to allow or not spatial touching a grabbable
- Add option in VisionOSHandsConfiguration to hide hands
- Version 2.0.4: compatibility with XRShared 2.0.2
- Version 2.0.3:
- Fix some cases where LineMesh points could not appear (normal improperly computed on the path)
- Add namespace & comments
- Version 2.0.2: Support direct pinch grabbing on SpatialTouchHandler (hardwareRigGrabberDisabled option, enabled by default), and multi spatial grabbing
- Version 2.0.1: Add define checks (to handle when Fusion not yet installed)
- Version 2.0.0: First release
Last updated on
Back to top