1.1 - VR Project Setup

Tutorial

·

Beginner

·

+10XP

·

90 mins

·

Unity Technologies

1.1 - VR Project Setup

By the end of this lesson, you will have a new Unity project with a big empty room that you will experience in VR.

This unit is part of the Create with VR course.

Overview Video

1. Open a new VR project

The first thing you have to do is create a new Unity project configured for VR.

1. Download and extract the Create with VR starter project:

  • Download the starter project file: Create with VR starter project.
  • To extract on macOS: double-click the downloaded file.
  • To extract on Windows: right-click the downloaded file and select Extract All.

2. Rename and relocate the project on your computer:

  • Located the folder called VR Room Project inside the extracted folder.
  • If you want, rename the project folder to “VR Room - [Your Name]”
  • Move the project folder to a logical directory on your computer (for example, a new folder called “Create with VR” on your desktop).

3. Add the VR room project to the Unity Hub:

4. Open the project in Unity 6.x:

  • From the Unity Hub, open your new project in the Unity Editor.
  • Make sure the Unity version is set to Unity 6.
  • If prompted to upgrade your project to a newer version of Unity 6, select Confirm.
  • If you don’t know how to open a project from the Unity Hub, follow the instructions in the Unity Hub manual.

5. Explore the contents of the starter project and how it differs from a typical empty project:

These are the packages needed to enable VR support, interaction systems, and rendering capabilities in your project.

Note: To filter and view only packages currently installed in the project, select In Project from the upper-left corner of the Package Manager window.

You should now have your new VR starter project open to an empty scene and understand which packages allow for compatibility with VR.

Note: These are packages that have been pre-configured in this starter project, since they are required for VR development in this course. If you want to learn how to configure a VR-ready project similar to this from scratch, follow the instructions in the Create a VR Starter Project from Scratch tutorial.

Unity also now offers a built-in VR Template available from the Unity Hub, which includes preconfigured settings, a rig, and sample scenes to help you get started more quickly.

Related resources:

2. Open and explore the starter scene

Before you run the project, you should choose a more interesting environment to experience in VR.

1. Rename and open the Starter scene:

  • From the Project window, open the Scenes folder.
  • Right-click the Create-with-VR-Starter-Scene and rename it “[Your_Name] Room”.
  • Double-click your renamed scene to open it.

2. Explore the contents of this scene and how it differs from a typical empty scene:

  • From the Hierarchy window, select the XR Origin (VR) GameObject and inspect the XR Origin component.
  • Select XR Origin (VR) > Camera Offset > Main Camera and inspect the Tracked Pose Driver component.
  • The Tracked Pose Driver component automatically moves a GameObject to match the real-world position and rotation of your VR headset or controllers.

  • The Controller GameObjects also needs these components to make sure they can be tracked.
  • In the Hierarchy window, use the foldout (triangle) to expand the XR Origin (VR) GameObject.
  • Select the LeftHand Controller GameObject and add a Tracked Pose Driver (Input System) component.
  • Select the settings button and then select the LeftTrackedPoseDriver preset. This will add all of the required Input Action References that the component needs to function.

  • Repeat this for the RightHand Controller, but this time select the RightTrackedPoseDriver preset.

3. Inspect the Input Action asset:

  • In the Hierarchy window, select the Input Action Manager GameObject and inspect the Input Action Manager component.
  • Double-click the XRI Default Input Actions asset to open the Input Actions Editor window.

  • This XRI Default Input Actions asset defines how your VR headset and controllers send input to your game. The Action Maps on the left group different kinds of inputs (like head tracking or hand movement). The Actions on the right show what’s being tracked (like your head's position and rotation). This setup enables Unity to respond to actions you perform in VR.

The InputActionsEditor showing the XRI Default Input Actions asset.

You can learn more about Input Actions in the Input System Documentation.

You should now have your new scene open and should also have a broad understanding of the components of the scene that make it different from a typical Unity scene.

3. Add a room and background

This empty scene would be boring to explore in VR, so you should add a room and a distant environment that will add some interest and provide more perspective when you’re in VR.

1. Add a room to the scene:

  • In the Project window, open the _Course Library > _Prefabs > Rooms folders.
  • We’ve provided you with three room styles: Modern, Rustic, and Traditional. Select one of the Room_[style] prefabs and drag it into the Hierarchy window.
  • In the Inspector window, set the Room_[style] GameObject’s Transform component’s position values to X = 0, Y = 0, and Z = 0.
  • You won’t need the Plane GameObject anymore, so select it in the Hierarchy window and then delete it.

2. Add an environment outside the room’s windows:

Now that you have a room, it would be great to have an environment outside the window.

  • Open the Course Library > _Prefabs > Environments folder.
  • Drag one Foreground GameObject and one Background GameObject into the Hierarchy window.
  • Position the Foreground and Background GameObjects so they’re visible as a backdrop through the windows of your room.

3. Adjust the sunlight in the room:

  • Change Directional Light GameObject’s Transform component’s Rotation property’s X and Y values to change the way sunlight enters your room.

You should now have Room, Foreground, and Background GameObjects in your scene from the course library, with sunlight entering the room at the desired angle.

4. Run the app with the Device Simulator

If you don’t have a VR headset connected—or simply prefer not to use one during testing—you can use the Device Simulator, which is included as part of the XR Interaction Toolkit. This tool allows you to test your scene directly in the Unity Editor using your mouse and keyboard. It’s especially useful for quick iterations and testing basic functionality without needing to put on a headset.

1. Add the Device Simulator prefab to the scene:

  • From the Project window, open the Samples > XR Interaction Toolkit > [version] > XR Device Simulator > XRDeviceSimulator folders.
  • Drag the XR Device Simulator prefab into the Hierarchy window.
  • Enter Play mode to test the simulator.

2. Experiment with the keyboard and mouse controls:

Note: To use the simulator effectively, a mouse with a clickable scroll wheel is suggested.

  • To control the camera: hold right-click.
  • To control the left controller: hold Left Shift or toggle with T.
  • To control the right controller: hold the Spacebar or toggle with Y.
  • To pan around with a device: move the mouse.
  • To rotate a device: hold the middle mouse button.
  • To reset the position and rotation of devices: press V.

3. Important: Disable the Device Simulator if you don’t plan to use it:

  • Select the Device Simulator GameObject then disable it in the Inspector window.
  • Leaving the Device Simulator GameObejct active when running the project on your device will cause problems.

You should now be able to look around your room with your mouse and keyboard using the Device Simulator.

Note: Please be aware that the updated Device Simulator now contains a helpful floating panel that displays all the available keyboard options when running the simulation.

5. Test in VR through Unity

If you’re using a Windows computer, follow this step to test on your device. Otherwise, skip this step.

If you are using a Mac for development, this step is not relevant. You’ll learn how to test your app in the next step when you build your app directly onto your device.

1. Install the OpenXR Plugin for desktop testing:

In order to run the project on your device through Unity, you need to install the correct plug-in for development. OpenXR is an open source API that connects Unity to supported VR hardware devices. It’s recommended that you use this plug-in, since it allows you to deploy to multiple devices through a single, standardized API.

  • From the main menu, select Edit > Project Settings, then select the XR Plug-in Management tab from the leftmost panel.
  • In the Windows, Mac, Linux tab, select OpenXR from the list of available Plug-in Providers to install that plug-in.

2. Resolve any warnings by setting up an interaction profile:

After adding the OpenXR plugin, there might be a warning or error icon that appears next to the plugin name.

  • If there are no warnings or errors, you can skip to the step below to connect your device through the Quest Link Software.
  • If there is a warning, select the warning icon to open the Project Validation window, which will tell you that you need to add an interaction profile for the device you’re using.
  • Select the Edit button to open the OpenXR settings panel.
  • In the Windows, Mac, Linux tab, make sure the Oculus Touch Controller Profile appears in the list of Interaction Profiles, then enable all available OpenXR Feature Groups.
  • If you’re using a different device, such as the Valve Index or HTC Vive, add its interaction profile instead.
  • There should no longer be any warnings in the XR Plugin Management panel. If there are, select them and follow the recommended steps to resolve them.
  • If you’re having trouble resolving warnings or errors, or if you need help troubleshooting, check out this detailed documentation on configuring the OpenXR plugin.

3. Connect your device through the Quest Link software:

If you're using a Meta Quest headset, you'll need the Quest Link software to connect it to your workstation. For any other VR hardware, please check the manufacturer's website for instructions on how to set up and connect your specific device.

  • Make sure your device is plugged into your computer using a compatible cable.
  • Make sure the Quest App is running and has successfully recognized your device.
  • If you haven’t yet downloaded the Quest App, you find it on the Meta Quest Link page.

4. Test the project on your device:

  • Make sure the XR Device Simulator GameObejct in your scene is disabled. If it is enabled, your head tracking won’t work.
  • Enter Play mode and put on your headset.

On a Windows computer, you should now be able to quickly test your app on your device through Unity.

6. Build and run on your device

If you’re using a Quest, follow this step to build the app onto your device. Otherwise, skip this step.

Since the Quest is a standalone device (meaning it doesn’t need to be connected to a computer), you can build an app and test it directly on the device, disconnected from your computer.

If you are on a Mac and can’t test your app through the Windows Quest software as in the previous step, this will be the primary way for you to test your app on your headset.

In order to build your app to the Quest headset, you’ll need to configure plug-ins for the Android build target.

1. Install the OpenXR for Android builds:

  • From the main menu, select Edit > Project Settings, then select the XR Plug-in Management tab from the leftmost panel.
  • From the XR Plug-in Management settings, select the Android tab, then select OpenXR from the list of available Plug-in Providers to install that plug-in.

Note: You’ll only have an Android tab if you installed the Android export module.

  • If you don’t see an option for OpenXR in the Android tab, first go back to the Desktop tab and select OpenXR there, then return to the Android tab.

2. Resolve warnings by setting up an interaction profile:

  • Select the new warning or error icon that appears to open the OpenXR Project Validation window,
  • If there’s an option to Fix All, select that to address some of the warnings.
  • A warning will likely still remain telling you that you need to add an interaction profile. Select the Edit button to open the OpenXR settings panel.
  • In the OpenXR settings panel, in the Android tab, select the Add (+) button to add the appropriate profile for your device.
  • For models of the Quest, select the Oculus Touch Controller Profile, then enable the Meta Quest Support feature groups.
  • If any additional errors or warnings appear, select the error or warning icons to resolve them.

3. Prepare your scene for building:

  • Make sure the XR Device Simulator GameObejct in your scene is disabled. If it is enabled, your head tracking won’t work.
  • From the main menu, select File > Build Profiles
  • Select Open Scene List.
  • Select Add Open Scenes to add your scene.

4. Switch to the Android build platform:

  • In the Platforms section, select Android.
  • Select Switch Platform and wait for your project to switch to the Android platform.

Note: Android will only show up as a possible build target if you successfully installed the Android Export Module during installation of the Unity Editor.

5. Select your device as the build target:

  • Make sure your VR device is turned on and plugged in.
  • Next to the Run Device dropdown, select Refresh, then select your VR device. Your device might show up as a device ID or as a device name.

Note: If your device doesn’t show up in the list, try putting on the device. It might prompt you to Allow USB debugging. If it is still not showing up in the list, try restarting your device, making sure it’s in Developer Mode, or restarting Unity.

6. Build and run your project on your device:

  • Select Build and Run.
  • When prompted to choose a location, create a new Builds” folder, then save your project as “[YourName] - VR Room - 1.1”.

Note: When you build your app for the first time, it might take several minutes to compile.

You should now be able to test the app on your device, untethered from your computer.

Note: The app is automatically saved onto your device in the Unknown Sources section of your App Library. You might need to follow steps to allow apps from unknown sources in order to locate your app.

Troubleshooting tips:

  • If the app runs, but it doesn’t take up the entire field of view, it’s likely a problem with plug-ins.
  • If the app runs, but the entire scene moves along with your head, it’s likely because you have the XR Device Simulator GameObject active or you do not have the Input Action Manager configured properly.
Optional Step

7. Test on other OpenXR-compatible devices

If you're using a different OpenXR-compatible headset, you can follow this step to test your project. Otherwise, feel free to skip it.

Most of these headsets require OpenXR, so make sure to install the OpenXR plugin in Unity and enable the feature set for your specific device. For detailed setup instructions, check the official website of your headset's manufacturer.

1. Configure the OpenXR Plugin for your device:

  • Follow the instructions on the OpenXR Manual page to install the OpenXR Plugin, enable it in XR Plugin Management, and configure it for your particular device.

2. Connect your device through the SteamVR app:

  • Make sure your device is plugged into your computer using a compatible cable.
  • Make sure the SteamVR app is running and has successfully recognized your device.

3. Test the project on your device:

  • Make sure the XR Device Simulator GameObject in your scene is disabled. If it’s enabled, your head tracking won’t work.
  • Enter Play mode and put on your headset.

You should now be able to quickly test your app on your headset through SteamVR.

8. Recap

New features:

  • Project is set up
  • Scene set up with room
  • Tested with Device Simulator
  • Run on device

New concepts and skills:

  • Pipelines for different types of hardware
  • Packages required for VR Development
  • VR scene vs typical Unity scene
  • Rig Simulator vs on-Device testing
  • Tethered vs Standalone testing

Next lesson:

  • VR Locomotion
Optional Step

9. Extension Activities

If you want to further develop your skills, explore new concepts, and improve your project, check out some of the extension activities below. Each one is tagged as [Easy], [Medium], [Difficult], or [Expert] to indicate the level of challenge and will also include a [Requires Programming] tag if relevant.

These are completely optional, but highly encouraged if you want to take your VR development to the next level.

1. Play with Directional Lighting [Easy]:

Experiment with the Directional Light GameObject to achieve the shadow and color you want in your room:

  • Try rotating the Directional Light GameObject about its X and Y axes.
  • Try adjusting the Color property of the Directional Light GameObject to match the color of light to the time of day.

2. Device Simulator Practice [Medium]:

Get comfortable using the basic functions of the XR Device Simulator.

  • Refer to the instructions in the step above for how to set up and use the XR Device Simulator GameObject.

Note: Remember to remove or disable the XR Device Simulator GameObject before running the app on your device.

3. Add a functioning clock [Expert] [Requires programming]:

Add a clock on the wall that either (a) tells the current time for the user in their local timezone or (b) tells the time you intend it to be in your VR room world.

  • Find a clock prefab in the _Course Library > _Prefabs > Objects > Electronics folder.

Hint: To access the system’s current time, use the DateTime.now property.

Complete this tutorial