Quick Start Tutorial
This tutorial will guide you through setting up a basic XR project using the QWR SDK. By the end, you'll have a working XR scene with hand tracking and basic interactions.
Prerequisites
Before starting this tutorial, make sure you have:
- Unity 2022.3 or newer installed
- Basic knowledge of Unity development
- QWR SDK downloaded from the GitHub repository
Step 1: Create a New Unity Project
- Open Unity Hub
- Click "New Project"
- Select the "3D Core" template
- Name your project (e.g., "QWR-Tutorial")
- Click "Create Project"
Step 2: Install QWR SDK
- Download the QWR SDK from the GitHub repository
- In your Unity project, go to Window > Package Manager
- Click the "+" button and select "Add package from disk..."
- Navigate to the downloaded SDK and select the
com.qwr.utilities/package.jsonfile - Once the QWR Utilities package is installed, repeat the process for the QWR Core package by selecting
com.qwr.core/package.json
Step 3: Install Required Dependencies
The QWR SDK requires several Unity packages to function properly. Install them through the Package Manager:
- Go to Window > Package Manager
- Click the "+" button and select "Add package by name..."
- Add the following packages one by one:
com.unity.xr.management(version 4.5.1 or newer)com.unity.xr.interaction.toolkit(version 3.2.1 or newer)com.unity.xr.openxr(version 1.15.1 or newer)com.unity.inputsystem(version 1.14.2 or newer)
Step 4: Configure XR Settings
- Go to Edit > Project Settings > XR Plugin Management
- Click "Install XR Plugin Management" if prompted
- In the XR Plugin Management tab, enable "OpenXR" under "Plugin Providers"
- Click on "OpenXR" in the left sidebar
- Under "Interaction Profiles", enable the profiles for your target devices (e.g., "Oculus Touch Controller Profile")
- Under "Features", ensure "Hand Tracking" is enabled if you plan to use it
Step 5: Create a Basic XR Scene
- Create a new scene (File > New Scene)
- Save the scene (File > Save As...) and name it "QWRTutorial"
Step 6: Add QWR XR Origin
- In the Project window, navigate to
Packages/QWR Core/Prefabs/QWR_XROrigin - Drag and drop the
QWR XR Originprefab into your scene - Position it at (0, 0, 0)
Step 7: Add a Ground Plane
- Right-click in the Hierarchy and select 3D Object > Plane
- Set its position to (0, 0, 0)
- Set its scale to (5, 1, 5) to make it larger
Step 8: Add Interactable Objects
Let's add some simple objects that can be grabbed:
-
Right-click in the Hierarchy and select 3D Object > Cube
-
Position it at (0, 1, 2)
-
Add a Rigidbody component (Add Component > Physics > Rigidbody)
-
Add a QWRInteractable component (Add Component > QWR > Interaction > QWRInteractable)
-
In the QWRInteractable component settings:
- Set "Grab Type" to "Both"
- Enable "Snap To Hand"
- Set "Physics Grab Mode" to "Kinematic"
-
Repeat steps 1-5 to create more objects with different shapes (Sphere, Cylinder) at different positions
Step 9: Add UI Elements
Let's add a simple UI panel:
-
Right-click in the Hierarchy and select UI > Canvas
-
Add a QWRUICanvas component to the Canvas (Add Component > QWR > UI > QWRUICanvas)
-
In the QWRUICanvas component settings:
- Set "Interaction Mode" to "Both"
- Set "Follow Type" to "BodyLocked"
- Set "Follow Distance" to 1.0
-
Right-click on the Canvas in the Hierarchy and select UI > Panel
-
Set the Panel's RectTransform to:
- Width: 300
- Height: 200
- Position: (0, 0, 0)
-
Right-click on the Panel in the Hierarchy and select UI > Button
-
Set the Button's RectTransform to:
- Width: 160
- Height: 40
- Position: (0, 0, 0)
-
Select the Text child of the Button and change the text to "Press Me"
Step 10: Add Button Functionality
- Create a new C# script named "ButtonHandler" in your project
- Add the following code to the script:
using UnityEngine;
using UnityEngine.UI;
using QWR.Core.UI;
public class ButtonHandler : MonoBehaviour
{
[SerializeField] private Button button;
[SerializeField] private GameObject targetObject;
[SerializeField] private Color newColor = Color.red;
private Color originalColor;
private Renderer targetRenderer;
private void Start()
{
if (button == null)
button = GetComponent<Button>();
if (targetObject == null)
targetObject = GameObject.Find("Cube");
if (targetObject != null)
{
targetRenderer = targetObject.GetComponent<Renderer>();
if (targetRenderer != null)
originalColor = targetRenderer.material.color;
}
button.onClick.AddListener(OnButtonClick);
}
private void OnButtonClick()
{
if (targetRenderer != null)
{
// Toggle color
if (targetRenderer.material.color == originalColor)
targetRenderer.material.color = newColor;
else
targetRenderer.material.color = originalColor;
}
}
}
- Add this script to the Button GameObject
- In the Inspector, drag the Cube object into the "Target Object" field
Step 11: Configure Input Actions
- In the Project window, navigate to
Packages/QWR Core/Inputs - Find the
QWR XRI Default Input Actionsasset - Double-click to open it in the Input Actions editor
- Review the default input mappings for hands and controllers
- Close the editor when done (no changes needed for this tutorial)
Step 12: Test Your Scene
- Save your scene
- Click the Play button to enter Play Mode
- You should now be able to:
- Look around using your HMD
- See your hands or controllers
- Grab and manipulate the cubes
- Interact with the UI button using ray interaction
If you don't have an XR device connected, you can still test basic functionality using Unity's XR Device Simulator:
- Go to Window > Package Manager
- Find and select "XR Interaction Toolkit"
- In the details panel, find "Samples" and import "XR Device Simulator"
- In your scene, add the XR Device Simulator prefab
- Press Play and use the keyboard/mouse to simulate XR input
Step 13: Build and Deploy
To build your application for an XR device:
- Go to File > Build Settings
- Add your current scene to the build
- Select your target platform (e.g., Android for Quest devices)
- Click "Switch Platform"
- Configure platform-specific settings if needed
- Click "Build" or "Build And Run"
Next Steps
Congratulations! You've created your first XR application with QWR SDK. Here are some suggestions for next steps:
- Try the Hand Interaction Tutorial to learn more about hand tracking features
- Explore the Controller Setup Tutorial for advanced controller configuration
- Check out the Multiplayer Setup Tutorial to add networking capabilities
- Review the API Reference for detailed information about available components
Troubleshooting
Hand Tracking Not Working
- Ensure your device supports hand tracking
- Check that hand tracking is enabled in OpenXR settings
- Verify that your hands are within the tracking volume of your device
Objects Not Grabbable
- Ensure objects have both a Collider and Rigidbody component
- Check that the QWRInteractable component is properly configured
- Verify that the grab type matches your input method (Hand, Controller, or Both)
UI Not Interactable
- Ensure the Canvas has a QWRUICanvas component
- Check that the interaction mode is set correctly
- Verify that the Canvas is within reach or visible