XR Step-by-Step 2023! Meta Quest: Setting up your Meta Quest XR Project! Unity 2022 + Open XR + XR Interaction Toolkit

Virtual and Augmented Reality together are now referred to as XR or “Extended-Reality”.
You’re in the right place at the right time to build something amazing in XR!
XR applications can be created in Unity for many devices, our focus will be on Microsoft Hololens 2 and the Meta Quest

In this blog post series we will focus on Meta Quest!

Check out other blog articles in this (and other) series!
Quick links to Lance’s latest XR Step-by-Step blog articles by device

Here is where we begin our XR experience journey! You should have the tools you need installed – if not, see the previous blog article in this series. We’ll be setting up a completely new XR experience, from beginning to end. This may seem like a lot, but take it one section at a time – the payoff is well worth it…

Full Step-by-Step Instructions!

Goals…

  1. Create a New Project
  2. Setup Unity Environment
  3. Change the Project to Build for the Quest
  4. Add a New Scene
  5. Customize Project Info
  6. Add OpenXR
  7. Add XR Interaction Toolkit (XRI)
  8. Setup New Scene
  9. Build and Run on Quest
  10. Bonus: Spinning Cube!

Download the finished code for this blog article @ Github Repo

Creating a New Project

  • Open Unity Hub and click New Project
  1. (New Project Window) -> Editor Version -> Select the latest version of 2022 in the drop down
  • (New Project Window) If you DO NOT have the 3D (URP) template already installed
    1. (Templates) Click the 3D (URP) template
    2. Click Download template
  • (New Project Window)
    1. (Templates) Click the 3D (URP) template
    2. (Project Name) Name your XR project
    3. (Location) Pick the directory in which you want the project to be created
    4. Click Create Project

Setup Unity Environment

  • Creating a project takes a couple of minutes – as the base projects are pretty large (~1.2GB) — here’s what we get!
  • Pro-Tip: (Toolbar) Window -> Layouts -> Wide
    • There are several different layouts of your Unity windows, I prefer “Wide” layout – but find the one that you love!
  • So we’re all talking about the same things, here are the parts of the Unity Window and what they are called.

Add a New Scene

  • Think of a Scene as a level in a game -or- a blank canvas on which to paint, we want to make a new one so you can learn how to make as many as you want for your XR experience in the future.
  1. (Project Window) Under Assets folder -> Click Scenes folder.
  2. (Project Window) Right-click anywhere in the open space
  3. Click Create
  4. Click Scene.
    • Name it Main Scene
  1. (Project Window) Double-Click on our new Main Scene so it shows up in the (Hierarchy Window).
  2. (Hierarchy Window) Right-click on the Main Camera
  3. Click Delete.
    • We do this because we we’re going to add a better camera for VR later.
    • Pro-Tip: You can also just click on Main Camera and hit the DEL key
  4. (Project Window) Click on SampleScene and hit DEL key

Change the Project to Build for the Quest

  • Unity can be used to build XR experiences for many device — for the Meta Quest it needs to be configured to be an Android build
  1. (Toolbar) Click File
  2. Click Build Settings
  1. (Build Settings) Click on the Add Open Scenes button -> Check the checkbox
    • If the original scene we deleted is still there, delete it
  2. (Platform) Click Android
  3. Click on the Switch Platform button

Customize Project Info

  • There are many ways to customize your Unity project settings, etc – we’ll start with easy ones in this article – but wanted to give you an idea on where to find settings like these.
  1. (Toolbar) Click Edit
  2. Click Project Settings…
  1. (Project Settings) Click Player
  2. Change Company Name, for example I use “HoloSoft”

Add OpenXR

  • So as more and more XR devices came to market of the past several years, more and more different libraries were being written for each of them. So while Unity could be used to develop for each, we couldn’t have one XR project that could be easily run across multiple devices – uggg…
  • OpenXR to the rescue. OpenXR is a standard that allows developers to (generally) write one Unity application and run it across multiple devices.
  • Not until THIS year (really only in the past several months) has OpenXR matured to the point where I’d recommend it over device specific libraries – now that it has – awesome XR experiences are even easier to create!
  1. (Project Settings) Click XR Plug-in Management
  2. Click Install XR Plugin Management
  1. (Project Settings) Click XR Plug-in Management
  2. Click the 1st tab (Windows, Mac, Linux, settings)
  3. Check Open XR
  • Click Yes to restart
  • After the project reloads
    1. (Project Settings) Click XR Plug-in Management
    2. Click the 3rd tab (Android settings)
    3. Check OpenXR
  1. (Project Settings) XR Plug-in Management -> Click OpenXR
  2. Click the 1st tab (Windows, Mac, Linux, settings)
  3. (Interaction Profiles) Click the “+” button
  4. Click Oculus Touch Controller Profile
  1. (Project Settings) XR Plug-in Management -> Click OpenXR
  2. Click the 3rd tab (Android settings)
  3. (Interaction Profiles) Click the “+” button
  4. Click Oculus Touch Controller Profile
  5. (OpenXR Feature Groups) Check Meta Quest Support
  1. (Project Settings) XR Plug-in Management -> Click Project Validation
  2. Click the 1st tab (Windows, Mac, Linux, settings)
  3. Click Fix or Fix All
    • Note, you may need to click on the text next the the Fix button and then the Fix button – not always the case, but seems to work when just clicking the Fix button doesn’t do it
  • (Project Settings) XR Plug-in Management -> Click Project Validation
  • Click the 3rd tab (Android settings)
  • Click Fix All, Fix or Edit next to anything that needs attention until we have all green checks!
    • Note, you may need to click on the text next the the Fix button and then the Fix button – not always the case, but seems to work when just clicking the Fix button doesn’t do it

Add XR Interaction Toolkit (XRI)

  • Building on top of the OpenXR standard, the XR Interaction Toolkit (XRI) is a high-level, component-based interaction system for creating VR and AR experiences. It provides a common framework for interactions and streamlines cross-platform creation.
  • This too has only very very recently become mature enough to be usable and thus why we’re fully embracing it to build the best XR experiences in Unity!
  1. (Toolbar) Click Window
  2. Click Package Manager
  1. (Package Manager) Click on dropdown arrow to open the menu
  2. Click Unity Registry
  1. Click in the search box -> Enter XR Interaction
  2. When XR Interaction Toolkit comes up -> Click Install
  • Click Samples tab
  • Click Import

Setup New Scene

Ok, so we’re going to setup our “Hello Cube!” (yes, my version of “Hello World!”)… 🙂

We’ll be adding a Plane (a flat square) for the ground, and a floating … wait for it … cube!

  1. (Hierarchy) Right-click -> Click 3D Object
  2. Click Plane
  • There’s our ground!
  1. (Hierarchy) Right-click -> Click 3D Object
  2. Click Cube
  1. (Hierarchy) Click Cube
  2. (Inspector) Edit the Transform values for the Cube with the following
  1. (Hierarchy) Right-click -> Click XR
  2. Click XR Origin (VR)
  1. (Hierarchy) Click XR Origin (XR Rig)
  2. (Inspector) XR Origin -> Tracking Origin Mode -> Click the dropdown arrow
  3. Click Floor
  1. (Game Window) Click the Game tab to see what the Camera will see… there’s our beautiful cube!

Build and Run on Quest

  • Ok, can’t wait anymore – we need to see this running on our Meta Quest!
  1. (Toolbar) Click File
  2. Click Build Settings…
  1. (Build Settings) Click the arrow dropdown next to Run Device
  2. If your Quest is connected to your computer, and you’ve given it permissions – you should see your device
  3. Click Build And Run
  1. (Build Android Window) Click New Folder
  2. Name the folder Install
  3. Click Open
  1. Name the file Install
  2. Click Save
  • Look at that! You’ve built your newest XR “Hello Cube!” and you’re seeing it on your Quest!!!
  • Congratulations for all your hard work – you’re now part of a very select group of geeks that have build their very own XR experience. 🙂

Bonus: Spinning Cube!

  • Now let’s see how easy Unity makes it to do some amazing things, today we’ll start by making the Cube spin!
  1. (Hierarchy) Click Cube
  2. (Inspector Window) Click Add Component
  1. (Hierarchy) Click Cube
  2. (Inspector Window) Click Add Component
  1. (Add Component Search) Type script
  2. Click New Script
  1. (Add Component Name) Name your new script Rotate
  2. Click Create and Add
  1. (Inspector) Rotate (Script) -> Double-click the Rotate script name
  • Visual Studio will launch and you’ll see two methods in your new C# script
    • Start(): Runs once before the cube is created in the scene.
    • Update(): Runs every frame, refresh is generally 60 to 90 frames/second.
    • Just add the two lines below and Save your changes!
  1. (Visual Studio) Add the code…

    public Vector3 rotationSpeed;
  2. Add the code…

    transform.Rotate(rotationSpeed);
  3. Click Save
  1. (Inspector Window) Change the Rotate script’s parameters to 0.1 for X, Y, and Z.
    • Feel free to play with these values – see what changing them does… What happens if you make them really fast?
  • Now run your project on your Quest!
    • Remember you can just click File -> Build And Run
  • That’s it! You should now see a rotating cube in your XR experience on your Quest! Congrats to you!

I always love feedback and suggestions for new XR / AI blog posts!

Go build something amazing in XR & AI! — Lance 🙂

Check out other blog articles in this (and other) series!
Quick links to Lance’s latest XR Step-by-Step blog articles by device

Leave a Reply