Skip to content

Adapt an existing Unity XR application

Tutorial - Adapting an existing Unity XR application to MiddleVR#

In this tutorial you will learn how to add MiddleVR to an existing Unity XR project and use MiddleVR Wands to emulate Unity XR controllers.

We will be demonstrating with the Unity 2022 LTS VR Template:

Requirements#

  • Unity 2022 LTS or more recent

  • XR Plugin Management 4.4.0

  • XR Interaction Toolkit 2.5.2

  • Input System 1.7.0

  • Make sure that you setup Unity XR correctly

  • Make sure that you setup a MiddleVR Wand correctly

Package#

  • Import the MiddleVR package:

    • Package Manager > Import package from tarball ... > C:\Program Files\MiddleVR3\unity_packages\com.middlevr.tgz
  • Import the MiddleVR XR Input package from

    • C:\Program Files\MiddleVR3\unity_packages\com.middlevr.xrinput.tgz
  • Add the MVRManager to your scene. See Tutorial - Using MiddleVR in Unity

  • On the MVRManager, select a development configuration file

  • If your project uses URP or HDRP, read Unity URP & HDRP

XR Controllers#

  • The position/orientation of the right controller will follow the MiddleVR node HandNode. Read more

  • The buttons and joystick will be the ones defined for your Wand

Run in editor#

Switching from MiddleVR to your XR headset is easy:

  • 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
  • If the MVRManager is not present in the scene or disabled:

    • The enabled Unity XR plugin will initialize and setup your XR headset.

More information: MiddleVR Unity XR Input usage

Cluster#

  • Make sure to read the part related to clustering in this tutorial

  • The position/orientation, joystick and buttons of the XR controllers will be synchronized in the same frame on the cluster server and cluster nodes. All deterministic XR interactions will thus be synchronized without any additional work

Build & run#

See MiddleVR Unity XR Input build.

Multiuser#

MiddleVR Unity XR Input is compatible with MiddleVR Netcode.

More information#

Unity XR Input.