Lukas Roper is the Lead Unity Developer at Virti. We've asked him to write a short article detailing how to add Vive Focus support to your projects.
With Oculus recently announcing their requirements for end-users to have Facebook accounts, we wanted to take a look at other headsets to support. The Vive Focus Plus was one of those headsets which I've tried to port to recently. I noticed, however, that the documentation was a bit fragmented and thought I'd write a guide about how to get started with a port.
For this guide, it'll presume you are using Unity 2019.4.0f or later. With that, you'll need to install the Android module. Easiest to install through the Unity Hub.
Need to download the package from: https://github.com/ViveSoftware/ViveInputUtility-Unity/releases/tag/v1.12.0
Before you start, I would highly recommend to back up your Unity project if you are attempting to add this to a pre-existing project.
To show the installation steps, I'll use an empty project.
Setting up the Unity project
1. Import the ViveInputUtility Unity package
2. Install XR Plugin Management
Once imported, install XR Plugin Management to the project. The easiest way to do this is to go to the project settings (Edit->Project Settings on the toolbar) and then select the XR Plugin Management. You may have completed this step already if you are porting from another VR platform.
3. Add build platforms
Once installed, you'll need to add the platforms you wish to support in the preferences window. Go to Edit->Preferences and click on the VIU Settings. Here you can select what platforms you want the Vive Input Utility to use. I'd recommend selecting the Simulator and WaveVR. If you aren't already building for Android, you'll need to first click on "Switch Platform". Once Unity has switched platform, you'll be able to select "Add Vive Registry". A pop up will appear which you need to select "Add". Then select "Add Wave XR Plugin Package" (I seemed to have to select this more than once for the installation to begin) and then finally you can check the WaveVR checkbox.
4. Run sample scene
The basics should now be installed. I would suggest running one of the sample scenes to ensure everything is correctly installed as I had issues after installation and had to do the installation process again for the issues to fix.
Go to HTC.UnityPlugin/ViveInputUtility/Examples/0.Tutorial and add the scene to your build settings. The plugin suggests to change build settings which I would suggest following, but from my testing, it's only a few of them that are hard requirements. The first is the Graphics APIs which where you have to remove Vulken. You can remove this in the Project Settings window.
The second setting to change in the "Default orientation". Again, this can be changed in the Project Settings and must be set to "Landscape Left":
And finally, the Minimum API Level must be set to 25 or higher. Again, this can be edited in the Player Settings:
That's the project setup, but before you can build and run, you need to set up the headset to allow developer access.
To enable Developer Mode:
- Click on the "Settings" icon.
- Navigate to "More Settings".
- Scroll down to the "Developer Options" section.
- Next, toggle on the "USB Debugging" option.
- A prompt should appear when you plug in the headset, asking for permission to connect to your PC. Similar to this:
- Click Ok.
Back in Unity project should now be able to click Build and Run and install to the headset.
If you need too, you can also adjust individual settings. Go back to Edit->Project Settings, expand XR Plug-in Management section and select WaveXRSettings:
These settings can't be previewed, so you'll need to build again. The main setting of interest is the render mode where certain shaders and graphics operations may not work using single-pass rendering. I had a crash with a library I was trying to use because of the render mode, so if you are noticing problems on the device, that would be the first thing to try and change.
Lukas will occasionally share more development details, Mario Kart perils or his love for Tetris Effect via his Twitter. If you have any questions, feel free to contact him.