Create an XR application in Unity, for both HTC Vive Focus Plus and Oculus Quest.
Ammad Raza
Sr Unity Developer / Software Engineer @ Proxify | AR VR XR Metaverse Development
Prepare XR Project.
1. Open Package Manager and install/update the following;
a. Oculus XR Plugin
b. XR Interaction Toolkit
c. XR Plugin Management
2. Register HTC Vive tools into your project by editing “Packages/manifest.json” file.
Follow this link to get scopedRegistry information: https://developer.vive.com/resources/vive-wave/sdk/320/vive-wave-xr-plugin/vive-registry/
3. After editing manifest.json, refresh your package manager, and open “My Registries”.
4. install “Vive Wave XR Plugin”.
5. Open Build Settings and Switch to Android Platform.
6. After Switching to Android platform, there is a possibility that “WaveXRPlayerSettingsConfigDialog” will appear. Select “Accept All”.
Prepare Simple XR Scene.
Note: Make sure you have “Prepare XR project” before start taking the following steps.
1. After preparing XR Project.
2. Open a new scene.
3. Right click in Hierarchy, find XR, and select “Stationary XR Rig”. This will prepare “Main Camera” for XR.
4. Look for “Main Camera” inside “XR Rig” GameObject, and add “Tracked Pose Driver” as new component, provide by the “XR Interaction toolkit”. Note: Please keep both “Tracked Pose Driver” components shown in this image.
5. Select GameObject named “XR Rig” and add “Locomotion System” as new component.
6. The Locomotion System requires a reference of XR Rig script, so apply the XR Rig script attached to the XR Rig GameObject.
7. Expend XR Rig GameObject and find the “LeftHand Controller” and the “RightHand Controller” GameObjects.
8. Remove “XR Controller (Action-based)” component from both controllers.
9. Add “XR Controller (Device-based)” as new component.
10. Create an empty GameObject as the Child of “LeftHand Controller” and the “RightHand Controller”. Rename the empty GameObject as “ModelTransform”.
11. Select the “LeftHand Controller” GameObject and give the “ModelTransform” as the reference in the “XR Controller (Device-based)”. Do the same for “RightHand Controller”.
12. Give a reference of any “hand models prefab” in “Model Prefab” field found in both Left and Right “XR Controller (Device-based)”.
13. Also make sure the “Controller Nodes” Field is defined correctly in both “XR Controller (Device-based)”.
14. Apply Sphere Collider components to both Controllers’ GameObject. Make sure to check “Is Trigger” and apply the Radius accordingly.
15. Create a Plane and a Cube. Place them in the scene accordingly.
16. Attach “XR Grab Interactable” as the new component to the Cube. Make sure to resize the cube accordingly.
17. To create a XR interactable UI, right click in the Hierarchy, find XR, select “UI Canvas”.
18. Apply some buttons to the Canvas. Make sure to apply some OnClick events, to test UI interaction.
To make an APK for HTC Vive Focus Plus.
Note: Make sure you have “Prepare XR project” before start taking the following steps.
1. Open “Project Settings” and find and select “Wave XR”.
2. Upon selecting Wave XR, “PlayerSettings Configure Dialog” Button will appear on the right side of the window, which will open a new window by the name of “WaveXRPlayerSettingsConfigDialog”, select “Accept all” and close the window.
3. Go back to the “Project Settings” and find and expend “Wave XR”.
4. Wave XR will be holding a sub-option by the name of “XRSDK”. Select XRSDK, and then select “Import Feature – Custom Andorid Manifest” button appeared on the right side of the window.
5. Again, go to the “Project Settings” find and select “XR Plugin Management”, which will show platforms on the right side of the Window.
6. Select Android as the platform, and then in the Plug-in Provides, check “WaveXR” and uncheck the rest.
7. Build and Run.
To make an APK for Oculus Quest.
Note: Make sure you have “Prepare XR project” before start taking the following steps.
1. Open “Project Settings” and find and select “XR Plugin Management”, which will show platforms on the right side of the Window.
2. Select Android as the platform, and then in the Plug-in Provides, check “Oculus” and uncheck the rest.
3. Make sure to delete the “AndroidManifest.xml” from Assets -> Plugins -> Android.
4. Build and Run.
Credit to "6freedom" for allowing me to conduct this research. Made with Unity 2019.4
Assistant Director for Media Technology
3 年Hey, this is great, thanks! I'm going through this (this is the most up-to-date guide I've seen so far). However, I'm having trouble finding the LeftHand and RightHand model prefabs. Have any suggestions for where to find those? I've run a search in the assets, and only scripts come up.