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 the XRHands addon, 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 NetworkSpatialGrabber
allows to have an additional "hand", not tied to an HardwareHand
/NetworkHand
pair.
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 hardwareRigGrabberDisabled
allows to choose between the 2 options :
- if
hardwareRigGrabberDisabled
is 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
hardwareRigGrabberDisabled
is set totrue
(default), 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 the XRHandsSync addon are used, the VisionOSHandsConfiguration
allows a quick automatic configuration of the hands for the Polyspatial vision OS platform.
The script:
- ensures that even if the hands are not detected for a short duration, the grabbing triggered by finger detection in
FingerDrivenControllerInput
still continues - uses
LineMesh
to display the beam used by aRayBeamer
component - 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)
- ensures that in case of no detection of the hands, the hand representation components do not try to fallback to controller, as there are no hand controller on visionOS
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
VolumeCamera
positions matches theHardwareRig
position (the one we usually teleport) - it also does the same for any
ARPlaneManager
that could be present in the scene, as ARFundation has the same requirement for teleportation
Dependencies
- XRShared
- VoiceHelpers
- VisionOSHelpers
- ConnectionManager
Download
This addon latest version is included into the Industries addon project
It is also included into the free XR addon project
Supported topologies
- shared mode
Changelog
- 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