Difference between revisions of "Set up VR in Unity"
(Created page with "<br/> '''Setting up VR and XR interaction toolkit project in Unity for versions 2019.4,2020.x & 2021.1'''<br/> 1. Install XR plugin management: edit / project settings / xr pl...") |
|||
(27 intermediate revisions by one other user not shown) | |||
Line 1: | Line 1: | ||
+ | This tutorial covers Unity 2021.1 and Earlier | ||
+ | |||
+ | For Unity 2021.2 and Later please see this tutorial: | ||
+ | '''[https://web.microsoftstream.com/video/c4ef83ef-8188-485d-bc02-2023e27a3504?list=studio | Unity VR and XR Interaction Toolkit 2021.2] ''' instead.<br/> | ||
<br/> | <br/> | ||
− | + | To learn how to publish to the oculus Quest Standalone see here:<br/> | |
− | + | http://interactionstation.wdka.hro.nl/wiki/Unity_Tutorials_from_the_Interaction_Station#VR_with_the_Oculus_Quest | |
− | + | ||
<br/> | <br/> | ||
− | 2. | + | Download a basic template scene for 2021.2 and XR interaction toolkit here:<br/> |
− | + | https://hrnl-my.sharepoint.com/:u:/g/personal/pellm_hr_nl/EXi13fy_XUxAre1-HP6Ye98B9EjkV0nLwa0or1TC9eW2og?e=4UggFG | |
+ | |||
<br/> | <br/> | ||
− | + | '''Setting up a VR and XR interaction toolkit project in Unity for versions 2019.4,2020.x & 2021.1'''<br/> | |
− | + | ||
− | + | This guide will show you how set up you Unity project to be visible inside a VR headset. The guide uses Unity's XR Plugin Management, with the XR Interaction Toolkit, and the OpenXR plugin. This will work on any desktop headset, but the guide assumes you're using an Oculus Quest headset. | |
− | + | ||
+ | In order to test this out on the computers at school, you'll need an Oculus Quest Headset, an Oculus Link usb cable (which is different from the Oculus charging cable), and the Oculus software installed on the computer. If the Oculus software doesn't open correctly you can find a fix [[About_Oculus_Quest#Fix_to_Enable_Oculus_Software_on_Student_Accounts|here]]. You'll need to have the Oculus software open and the link mode enabled in the headset.<br/> | ||
+ | |||
+ | |||
+ | |||
+ | '''1. Install XR plugin management:'''<br/> | ||
+ | edit / project settings / xr plugin management / install xr pluging management<br/> | ||
+ | |||
+ | [[File:01_project_settings.png|200px]]<br/><br/> | ||
+ | [[File:02_xr_plugin_management.png|400px]]<br/> | ||
<br/> | <br/> | ||
− | + | ||
− | + | '''2. Add Oculus to the plugin providers:'''<br/> | |
− | + | tick the Oclus box (if using oculus) or OpenXR if using any other headset <br/> | |
− | + | OpenXR will work also with the Oculus on the desktop, but if you want to publish the Quest in standalone mode only the Oculus plugin will work. <br/> | |
+ | [[File:03_open_xr_plugin.png|400px]]<br/> | ||
+ | Choose your PlayMode Open XR Runtime <br/> | ||
+ | This will be Oculus, or Steam VR if you're using the Index or the Vive. <br/> | ||
+ | [[File:04_open_xr_playmode.png|400px]]<br/> | ||
+ | |||
+ | '''3. Enable the Interaction Profile for Oculus:'''<br/> | ||
+ | Or choose the profile that matches the headset you're using.<br/> | ||
+ | [[File:05_xr_interaction_profile.png|400px]] | ||
+ | |||
+ | '''4.Enable preview Packages in the Package Manager:'''<br/> | ||
+ | Window / Package Manager<br/> | ||
+ | [[File:07_xr_packagemanager.png|400px]]<br/> | ||
+ | in the package manager click on the gear and choose "advanced project settings"<br/> | ||
+ | under "Advanced Settings" tick on "Enable Preview Packages"<br/> | ||
+ | |||
+ | [[File:06_xr_advanced_package_settings.png|400px]]<br/> | ||
+ | [[File:07_xr_enable_prerelease.png|400px]]<br/> | ||
<br/> | <br/> | ||
− | + | ||
− | + | ||
+ | '''5.In the package Manager install "XR Interaction Toolkit":'''<br/> | ||
+ | at the top left of the package manager select Packages: Unity Registry<br/> | ||
+ | |||
+ | [[File:08_xr_unity_registry.png|400px]]<br/> | ||
+ | Find and select XR interaction Toolkit<br/> | ||
+ | click install in the lower right corner of the package manager<br/> | ||
+ | [[File:09_xr_xr_interactiontoolkit.png|400px]] | ||
<br/> | <br/> | ||
− | + | ||
− | Assets / Samples / XR interaction toolkit / 1.... / Default Input Actions / | + | '''5b. In the XR Interaction Toolkit Package samples, install the Default Input Actions:'''<br/> |
− | select "XRI Default Left Controller" - In the inspector click "Add to ActionBasedController default" | + | Download and import the Default Input Actions<br/> |
− | same for right | + | [[File:10_xr_samples_default_input_actions.png|400px]]<br/> |
+ | |||
+ | |||
+ | |||
+ | |||
+ | '''6.Locate the Default Input Actions folder you've just imported:'''<br/> | ||
+ | You'll find this in the Project tab under assets:<br/> | ||
+ | Assets / Samples / XR interaction toolkit / 1.*.*.*.* / Default Input Actions /<br/> | ||
+ | [[File:11_xr_default_input_actions.png|400px]]<br/> | ||
+ | [[File:12_xr_default_input_actions_pt2.png|400px]]<br/> | ||
+ | select "XRI Default Left Controller" - In the inspector click "Add to ActionBasedController default"<br/> | ||
+ | [[File:13_xr_default_input_actions_left.png|600px]]<br/> | ||
+ | repeat the same for the right controller<br/> | ||
+ | [[File:13_xr_default_input_actions_right.png|600px]]<br/> | ||
<br/> | <br/> | ||
− | + | ||
− | under Action Based Controller in the filter add | + | '''7.Change the filter for the ActionBasedController in the Preset Manager:'''<br/> |
− | "left" to the filter for "XRI Default left Controller" | + | edit / project settings <br/> |
− | "right" to the filter for "XRI Default right Controller" | + | in the project settings window select "preset manager" <br/> |
+ | under Action Based Controller in the filter add<br/> | ||
+ | "left" to the filter for "XRI Default left Controller"<br/> | ||
+ | "right" to the filter for "XRI Default right Controller"<br/> | ||
+ | |||
+ | [[File:14_xr_preset_manager.png|600px]]<br/> | ||
<br/> | <br/> | ||
− | + | ||
− | Game Object / XR / XR Rig Action Based | + | |
− | <br/> | + | |
− | + | '''8.now you can add an XR Rig - Action Based to your project:''' | |
− | add a component called | + | Game Object / XR / XR Rig Action Based<br/> |
− | "Input Action Manager" | + | [[File:15_xr_xr_rig.png| 500px]]<br/> |
+ | |||
+ | |||
+ | |||
+ | '''8b.Add "Input Action Manager" to the XR rig:'''<br/> | ||
+ | In the inspector for the "XR rig" Game Object , add a component called "Input Action Manager"<br/> | ||
+ | [[File:16_xr_input_action_manager.png|600px]]<br/> | ||
+ | |||
in the component under "Action Assets" change the number to 1 and expand | in the component under "Action Assets" change the number to 1 and expand | ||
click on the dot to select "XRI default input actions"<br/> | click on the dot to select "XRI default input actions"<br/> | ||
− | 9. You may have to enable the following setting: "Window/Analysis/Input Debugger/Options/Lock Input to Game View" | + | [[File:17_input_actions.png|600px]]<br/> |
+ | [[File:17_input_actions_b.png|400px]]<br/> | ||
+ | |||
+ | |||
+ | |||
+ | '''9.Set the XR rig tracking origin mode to Floor:'''<br/> | ||
+ | [[File:16_xr_rig_floor.png|400px]]<br/> | ||
+ | |||
+ | |||
+ | |||
+ | '''10.Lock input to game view:'''<br/> | ||
+ | You may have to enable the following setting: "Window/Analysis/Input Debugger/Options/Lock Input to Game View"<br/> | ||
+ | [[File:18_input_debugger.png|600px]]<br/> | ||
+ | [[File:19_lock_input_to_game_view.png|600px]]<br/> | ||
+ | |||
+ | |||
+ | |||
+ | '''11.Enter playmode and put on the headset'''<br/> | ||
+ | It should work now. Reflect on how annoying it is to follow all of these steps. It really should be simpler, shouldn't it? | ||
+ | |||
+ | |||
+ | [[Category:Virtual Reality]][[Category:Unity]] |
Latest revision as of 15:41, 21 November 2022
This tutorial covers Unity 2021.1 and Earlier
For Unity 2021.2 and Later please see this tutorial:
| Unity VR and XR Interaction Toolkit 2021.2 instead.
To learn how to publish to the oculus Quest Standalone see here:
http://interactionstation.wdka.hro.nl/wiki/Unity_Tutorials_from_the_Interaction_Station#VR_with_the_Oculus_Quest
Download a basic template scene for 2021.2 and XR interaction toolkit here:
https://hrnl-my.sharepoint.com/:u:/g/personal/pellm_hr_nl/EXi13fy_XUxAre1-HP6Ye98B9EjkV0nLwa0or1TC9eW2og?e=4UggFG
Setting up a VR and XR interaction toolkit project in Unity for versions 2019.4,2020.x & 2021.1
This guide will show you how set up you Unity project to be visible inside a VR headset. The guide uses Unity's XR Plugin Management, with the XR Interaction Toolkit, and the OpenXR plugin. This will work on any desktop headset, but the guide assumes you're using an Oculus Quest headset.
In order to test this out on the computers at school, you'll need an Oculus Quest Headset, an Oculus Link usb cable (which is different from the Oculus charging cable), and the Oculus software installed on the computer. If the Oculus software doesn't open correctly you can find a fix here. You'll need to have the Oculus software open and the link mode enabled in the headset.
1. Install XR plugin management:
edit / project settings / xr plugin management / install xr pluging management
2. Add Oculus to the plugin providers:
tick the Oclus box (if using oculus) or OpenXR if using any other headset
OpenXR will work also with the Oculus on the desktop, but if you want to publish the Quest in standalone mode only the Oculus plugin will work.
Choose your PlayMode Open XR Runtime
This will be Oculus, or Steam VR if you're using the Index or the Vive.
3. Enable the Interaction Profile for Oculus:
Or choose the profile that matches the headset you're using.
4.Enable preview Packages in the Package Manager:
Window / Package Manager
in the package manager click on the gear and choose "advanced project settings"
under "Advanced Settings" tick on "Enable Preview Packages"
5.In the package Manager install "XR Interaction Toolkit":
at the top left of the package manager select Packages: Unity Registry
Find and select XR interaction Toolkit
click install in the lower right corner of the package manager
5b. In the XR Interaction Toolkit Package samples, install the Default Input Actions:
Download and import the Default Input Actions
6.Locate the Default Input Actions folder you've just imported:
You'll find this in the Project tab under assets:
Assets / Samples / XR interaction toolkit / 1.*.*.*.* / Default Input Actions /
select "XRI Default Left Controller" - In the inspector click "Add to ActionBasedController default"
repeat the same for the right controller
7.Change the filter for the ActionBasedController in the Preset Manager:
edit / project settings
in the project settings window select "preset manager"
under Action Based Controller in the filter add
"left" to the filter for "XRI Default left Controller"
"right" to the filter for "XRI Default right Controller"
8.now you can add an XR Rig - Action Based to your project:
Game Object / XR / XR Rig Action Based
8b.Add "Input Action Manager" to the XR rig:
In the inspector for the "XR rig" Game Object , add a component called "Input Action Manager"
in the component under "Action Assets" change the number to 1 and expand
click on the dot to select "XRI default input actions"
9.Set the XR rig tracking origin mode to Floor:
10.Lock input to game view:
You may have to enable the following setting: "Window/Analysis/Input Debugger/Options/Lock Input to Game View"
11.Enter playmode and put on the headset
It should work now. Reflect on how annoying it is to follow all of these steps. It really should be simpler, shouldn't it?