Computer Graphics for Virtual  
and Augmented Reality  
Lecture 03 Virtual Reality in Unity  
(Project Setup)  
Edirlei Soares de Lima  
<edirlei.lima@universidadeeuropeia.pt>  
Virtual Reality in Unity  
Unity XR system offers support for Virtual Reality (VR), Mixed  
Reality (MR), and Augmented Reality (AR).  
Project Setup  
Setup a new VR Project in Unity:  
1
2
. Create new 3D Project.  
. Install the "XR Plugin Management" in the Package Manager  
Window -> Package Manager).  
. Install the "XR Interaction Toolkit" in the Package Manager (Window  
(
3
-
> Package Manager).  
Add the package by name: com.unity.xr.interaction.toolkit  
Import the samples: Input Actions and Simulator  
4. Open the Project Settings (Edit -> Project Settings) and select the XR  
Plug-in Management.  
5. Select a Plug-in Provider to enable it for the corresponding build  
target.  
XR Device Simulator  
The XR Device Simulator is a tool of the XR Interaction Toolkit.  
It handles mouse and keyboard input from the user and uses it to  
drive simulated XR controllers and an XR head-mounted display.  
The new input system is required.  
XR Device Simulator  
Setup the Simulator:  
1. Drag and drop the XR Device Simulator prefab in the scene.  
2
. Enable the default controller actions: “XRI Default Left Controller”  
and “XRI Default Right Controller”.  
3
4
5
6
. Open the Project Settings and select Present Manager. Then, name  
the controller presents "Left" and "Right“.  
. Create an XR Rig in the scene: GameObject -> XR -> XR Origin.  
The action will be automatically assigned in the XR Controllers.  
. Add an Input Action Manager component to the XR Origin  
GameObject.  
. Add an action asset in the Input Action Manager component and  
select the asset "XRI Default Input Actions".  
XR Device Simulator Controls  
HMD:  
RIGHT CLICK + MOUSE MOVE: Moves the HMD (X and Y)  
RIGHT CLICK + MOUSE SCROLL: Moves the HMD (Z)  
LEFT CTRL + RIGHT CLICK + MOUSE MOVE: Rotates the HMD  
Left Hand:  
LEFT SHIFT + MOUSE MOVE: Moves the left hand (X and Y)  
LEFT SHIFT + MOUSE SCROLL: Moves the left hand (Z)  
LEFT SHIFT + LEFT CTRL + MOUSE MOVE: Rotates the left hand  
LEFT SHIFT + G (hold): grabs an object with left hand  
Right Hand:  
SPACE + MOUSE MOVE: Moves the right hand (X and Y)  
SPACE + MOUSE SCROLL: Moves the right hand (Z)  
SPACE + LEFT CTRL + MOUSE MOVE: Rotates the right hand  
SPACE + G (hold): grabs an object with right hand  
Further Reading  
Unity Documentation:  
Unity XR:  
https://docs.unity3d.com/2022.1/Documentation/Manual/XR.html  
XR Interaction Toolkit:  
https://docs.unity3d.com/Packages/com.unity.xr.interaction.toolkit@2.0/manual/index.html