# Setting up your project

These instructions were written for **Unity version 2022.3.4f1.** They may not work for future versions.

## Create new project

In Unity Hub create a new project with the **3D (URP)** template. Give it a name and choose its locations.

<figure><img src="https://1313564241-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fs3fEUGujmVHeZsdShSEN%2Fuploads%2FD4E3a1PeUZSbXEj7wHsC%2FScreenshot%202023-10-05%20at%204.12.08%20PM.png?alt=media&#x26;token=3b4367ef-cdab-4ad4-aa97-49e9df279b65" alt=""><figcaption></figcaption></figure>

## Install packages

1. Go to the menu item **Window > Package Manager**&#x20;
2. Switch Packages from *In Project* to **Unity Registry**\
   ![](https://1313564241-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fs3fEUGujmVHeZsdShSEN%2Fuploads%2FWard9Ko84cAeXTMdqShN%2F002_UnityRegistry.png?alt=media\&token=05e2f936-4455-49c1-ae40-06e58bb4f18b)
3. Under *Features* install:
   * **VR** (2 packages)
4. After installing you will be prompted with a warning: "Do you want to enable the backends?" Click **"Yes"**
5. Under *Packages* install:
   * **XR Interaction Toolkit**&#x20;
   * **XR Plugin Management** (This should already be installed with VR Features)
6. A second dialog titled "*XR InteractionLayerMask Update Required*" will pop up. Click **"I Made a Backup, Go Ahead!"**
7. Before closing the *Package Manager* window, go to the *XR Interaction Toolkit* package and click on the *Samples* tab. Import **Starter Assets.**

## Edit project settings

1. Go to the menu item *Edit > Project Settings*
2. Under **XR Plug-in Management,** click the *Android* tab. Check the box for **OpenXR**
3. Under **XR Plug-in Management > OpenXR**
   * Click the "+" under *Interaction Profiles* to add a new profile for your device:
     * Quest 2 > Oculus Touch Controller Profile
     * Quest Pro > Meta Quest Touch Pro Controller Profile
   * Under OpenXR Feature Groups, check the box for **Meta Quest Support**
4. Go to **Player**:. Change **Company** and **Product Name**. Avoid spaces and symbols.

## Edit build settings

These instructions are for Mac development.

1. Go to *File > Build Settings*. Under *Platform* choose **Android**.
2. Click the button **"Switch Platform"**
3. Connect your device to your computer via USB
4. Under *Run Device* click *"Refresh"* then choose your device from the List. You may need to click allow from within the device.
5. Click **Add Open Scenes** to include the SampleScene in the build.

## Setting up the scene

### Creating the XR Origin

1. Add an XR Origin by going to the Hierarchy add **XR > XR Origin**. \ <mark style="color:red;">**NOTE:**</mark> <mark style="color:red;"></mark><mark style="color:red;">Do</mark> <mark style="color:red;"></mark><mark style="color:red;">**NOT**</mark> <mark style="color:red;"></mark><mark style="color:red;">select the XR > Device-based > XR Origin</mark>\
   ![](https://1313564241-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fs3fEUGujmVHeZsdShSEN%2Fuploads%2FqH7omKly7pKExRiJmLVB%2FXR%20Origin.png?alt=media\&token=eea03f60-d63e-4038-9c12-8328e3c0a582)
2. The select the left hand controller objects inside the Camera Offset inside the XR Origin.\
   ![](https://1313564241-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fs3fEUGujmVHeZsdShSEN%2Fuploads%2FaRsU2UPpWOxNrpVfqcVu%2FLeftHandController.png?alt=media\&token=085d4ad0-005b-43ac-96a7-470239e091ea)
3. On the *XR Controller (Action-based)* component of the LeftHandController click the preset menu and choose: **XRI Default Left Controller**.\
   ![](https://1313564241-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fs3fEUGujmVHeZsdShSEN%2Fuploads%2FsZHG8Izgb3jz3NZxbf2i%2FControllerPresets.png?alt=media\&token=c84d79dc-3103-4d7b-a583-54afad888767)
4. Repeat the above for the *RightHandController* choosing the *XRI Default Right Controller* prese&#x74;*.*

### Adding controller models

You can add models for physical controller to help show where they are in space by adding a mesh object or prefab object.

Unity provides generic controller objects for the left and right hand *XR Interaction Toolkit > \[VERSION] > Starter Assets > Prefabs > XR Origin Pieces > XR Controller Left* (and Right). Meta provides [3D models](https://developer.oculus.com/downloads/package/oculus-controller-art/?locale=en_GB) of their physical controllers.

1. Add your model or prefab as a child of your *LeftHandController* object. Make sure the nested models Transform position is set to (x: 0, y: 0, z: 0). If you add the object directly from the your *Project Assets* it should be positioned correctly.
2. After nesting your model in the *LeftHandController* object, select the *LeftHandController* and in the inspector find the section labeled *Model* in the *XR Controller* component. Click and drag the controller model from the heirarchy into the drop down box labeled **Model Prefab**.<br>

   <figure><img src="https://1313564241-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fs3fEUGujmVHeZsdShSEN%2Fuploads%2F0CGQlnue9orRw1yfXoLx%2FDragControllerModel.gif?alt=media&#x26;token=8ba48d02-d60c-414b-8d1a-121a0e203b43" alt=""><figcaption></figcaption></figure>
3. Repeat steps for the *RightHandController*.
