Unity XR Input#
MiddleVR XR Input#
This is a package that allows you to emulate Unity XR controllers using MiddleVR's Wands.
It simplifies the porting of XR applications to MiddleVR.
It also enables an app to be used with both MiddleVR and an XR headset with the same build.
You can now use your wands with Unity's XR interaction toolkit.
Installation#
Packages#
You application needs to include the following packages:
-
XR Plugin Management 4.5.0
-
XR Interaction Toolkit 3.0.7
-
Input System 1.11.2
-
MiddleVR
-
MiddleVR XR Input
Setup#
MiddleVR Setup#
- Make sure to have at least one wand correctly setup in your MiddleVR configuration. See Configuring the Wand documentation.
Note: You can find a template configuration called VR > UnityXR.vrx
Unity Setup#
Usage#
Controllers#
If the MVRManager
is present and enabled in the scene MiddleVR will automatically create on the first play:
-
An XR controller named
RightWand
(with usageRightHand
) for the first wand in your configuration -
An XR controller named
LeftWand
(with usageLeftHand
) if a second wand exists in your configuration
All the GameObjects containing a MVRWand
script will also be disabled so that MiddleVR's interactions don't interfere.
Buttons#
Button 0 will act both as a TriggerButton
and a GripButton
.
Button 1 will act only as a GripButton
.
Button 2 to 4 don't have any specific usage.
Position and orientation#
The position and orientation of the RightWand
will be copied from the first found MiddleVR 3D Node in this list:
HandNode
,RightHandNode
,Hand
,RightHand
,HandNodeRight
,HandRight
,User0.HandNode
The position and orientation of the LeftWand
will be copied from the first found MiddleVR 3D Node in this list:
LeftHandNode
,LeftHand
,HandNodeLeft
,HandLeft
,User1.HandNode
Editor#
-
If the MVRManager is present in the scene and enabled:
- MiddleVR will automatically disable any XR plugin such as OpenXR, Oculus or OpenVR.
- The XR controllers will move according to your MiddleVR configuration
MVRTools.GetMVRManager()
will return theMVRManagerScript
: Just check if the result is notnull
if you are only interested in knowing if MiddleVR is active or not. See Unity Cluster - Advanced
-
If the MVRManager is not present in the scene or disabled:
- MiddleVR will disable all scripts with attribute
[MVRDisable(IfNoMVR=true)]
. - The enabled Unity XR plugin will initialize and setup your XR headset.
MVRTools.GetMVRManager()
will returnnull
.
- MiddleVR will disable all scripts with attribute
Build#
PC-VR#
By default the Unity VR Template builds with IL2CPP, which is great for mobile VR headsets, but is not supported by MiddleVR.
When building for Windows, make sure to set the scripting backend to Mono:
Player Settings > Configuration > Scripting Backend
.
You can safely set it back to IL2CPP if you want to build for Android (Meta Quest for example) or iOS/iPadOS/VisionOS (Vision Pro for example).
More information: Meta Quest development in Unity
Standalone XR headset#
You can safely switch your build platform to Android or iOS/iPadOS/VisionOS (Vision Pro for example) and IL2CPP and Build and run the resulting build. MiddleVR will automatically be disabled at runtime.
Execution#
You can use the same build to run MiddleVR or on a headset.
If MiddleVR detects the --config
parameter on the command line, it will disable all XR plugins.
If the parameter is not found, the MVRManager
will be disabled, along with all scripts with the matching
[MVRDisable]
attribute.
Run with MiddleVR#
Start through MiddleVR config or via the command line.
Run in PC-VR XR headset#
Simply start the .exe file
Run in standalone XR headset#
Use your standard method to start your app.
Multiuser#
MiddleVR Unity XR Input is compatible with MiddleVR Netcode.
Known limitations#
Multiview systems are not currently supported.