Unity 2022 LTS has been released and I’ve taken it as a sign to redo my VR Basics tutorials. The XR Interaction Toolkit is now at version 2.3.2 and when I did my basics tutorials, it was still at 2.0.0.
There’s a ton of changes and things to explore, so let’s go back to basics and get things set up.
Installing Unity 2022 LTS
Installing Unity 2022 LTS may not sound like the latest version for Unity, but for development purposes it is. Unity releases their most recent and stable version of Unity roughly 6 months after a new year. The most recent version in 2022 was the 2021 LTS and now we have been blessed with the 2022 LTS midway through 2023.
To download, we’ll need to get Unity Hub and download the version of Unity we want from there. You can find Unity Hub here.
Once downloaded, installed and opened, we’ll be greeted with this!
To install the correct editor version, do the following.
- Select Installs
- Select Install Editor
- Select 2022.3.2f1 (Or the most recent version of 2022)
- Select Android Build Support, OpenJDK, and Android SDK & NDK Tools
- Select Continue
- Select 2022.3.2f1 (Or the most recent version of 2022)
- Select Install Editor
It’ll take some time, but once it’s finished, Unity 2022 LTS will be ready for use!
Creating a New Project
Let’s start a new project.
- Select New Project
- Use Editor Version Dropdown at the top center of the window to select version 2022 LTS
- Select 3D (URP) as the base template to build the project
- Set project name to ‘VR Basics’
- Create Project
XR Plugin Management
In order to get VR working, we’re going to need to be able to take input from a wide range of different devices. In order to handle all the different plugins required to deploy to all these different devices, we’re going to need to install the XR Plugin Manager.
- Edit -> Project Settings -> XR Plug-in Managment
- Install the XR Plug-in Manager
- Under the PC Tab
- Select Open XR (May cause editor to restart)
- Under the Android Tab
- Select Open XR
- Select OpenXR (under XR Plug-in Management)
- Under the PC Tab
- Add Interaction Profiles you’re deploying to (ie. Oculu, Vive, Index, ect) using the ‘+’ sign
- Under the Android Tab
- Add Interaction Profiles you’re deploying to (ie. Oculu, Vive, Index, ect) using the ‘+’ sign
Importing the XR Interaction Toolkit
Next, we’re going to need a framework so we can develop for VR. Frameworks and toolkits help provide a ton of functionality so we don’t have to build everything from the ground up. The one that I’m going to use for this tutorial series is the XR Interaction Toolkit. To install it, do the following.
- Window -> Package Manager
- Method 1
- Use top left dropdown and select Unity Registry
- Search for XR Interaction Toolkit (search is in top right)
- Method 2
- If the XR Interaction Toolkit doesn’t appear in the search, do the following
- Use top right plus to ‘Install package form git URL ‘com.unity.xr.interaction.toolkit’
- This will automatically install the package
- Method 1
- Select XR Interaction Toolkit
- Samples
- Import Starter Assets
- Samples
With that, we can now start building out our testing environment!
Testing Environment and XR Rig
Let’s setup our testing environment. For this tutorial, we’ll keep it simple and just add a Plane for us to stand on.
- Right click in Hierarchy -> 3D -> Plane
I like to add a material to my plane just so it isn’t a dull grey color, but it isn’t necassary.
Next, we need to set up the XR Rig. This will be responsible for handling our camera, hands and well… Everything!!!!
- Right click in Hierarchy -> XR -> XR Origin VR
- Expand out XR Origin
- Select LeftHand Controller
- Remove Sorting Group, XR Interactor Line Visual, Line Renderer, XR Ray Interactor
- Select RightHand Controller
- Remove Sorting Group, XR Interactor Line Visual, Line Renderer, XR Ray Interactor
- Select LeftHand Controller
- Select LeftHand Controller
- In the top right of the XR Controller component, select the middle icon
- Select XRI Default Left Controller
- In the top right of the XR Controller component, select the middle icon
- Repeat the above steps, but for the Right Controller
As a bonus, we can also have these automatically apply when we generate a XR Origin
- Assets -> Samples -> XR Interaction Toolkit -> 2.3.2 -> Starter Assets
- Select XRI Default Left Controller
- At the top of the Inspecter, Select Add to ActionBasedController default
- Repeat for the XRI Default Right Controller
- Select XRI Default Left Controller
Last, we need to connect it using the Preset Manager.
- Edit -> Project Settings -> Preset Manager
- Enter ‘left’ in the empty slot next to XRI Default Left Controller
- Enter ‘right’ in the empty slot next to XRI Default Right Controller
Now when we create a XR Origin, it’ll automagically fill out our Input Actions for each controller.
Input Action Manager
The last piece to the XR Origin puzzle is the Input Action Manager. As the name implies, it’s responsible for managing all our Input Actions from our controllers.
- Right click in Hierarchy -> Create Empty – name it ‘Input Action Manager’
- Select Input Action Manager
- Add Component – Input Action Manager
- Select Plus Sign under Action Assets
- Add the XRI Default Input Actions into the empty slot
- Add Component – Input Action Manager
With the Input Action Manager set, we can now boot up the Scene with our headset connected and see if it’s working.
Conclusion
For tracking purposes, I’ve attached two small spheres on the Left and Right Controllers of the XR Origin. I suggest doing the same to make sure the controller tracking is working.
With that, we now have set the stage for being able to develop VR games!
Next week I’ll be covering the Input Mapping and Hand Animations so we don’t need to settle for using spheres as hands.