To begin developing immersive experiences with Unity and VRTK, we must first download and install the required tools. These tools include: Unity, an integrated development environment (IDE), and Git for either Windows or Mac.
I’m not going to lie to you: Setting all of this up might not be easy. There are many steps, and many points at which something could go wrong. I will try to be as agnostic in regard to platform as I can, but I am accustomed to developing with Unity on a PC running Windows 10. Unity is cross-platform, though, for both your development environment as well as deployments. Both Windows and MacOS are supported. To be certain that I provide you with the most accurate depiction of what I know and have learned, I will refrain from speculating about what you might encounter in your environment. At the same time, I will do my best to anticipate errors you might receive while downloading, installing, and running your program.
With all that said, the resources available online for the tools we need to run Unity and VRTK on our machines are abundant. All that you require to find the answers you might need is enough information to know the question you want to ask. It is with that axiom in mind, the standard operating procedure of the developer’s secret weapon—Google—that I relay to you what I know. VR and the tools for its creation like VRTK are a bleeding-edge medium. As such, unknowns, hiccups, and missteps abound. I will do my best to make the trial by fire as illuminating as it will be hot.
Download and install Unity.
Download and install an IDE.
Download and install Git.
Clone the VRTK GitHub repository.
Set up the Unity Editor for a VR project.
Run the VRTK sample scene in Unity.
Downloading and Installing Unity
Let us begin. Unity is a robust 3D engine that provides an interface to create many kinds of experiences. Because of its versatility, Unity can demand significant resources from your local machine. Before downloading and trying to install Unity on your computer, confirm that your system meets the minimum standards for Unity development. As of this writing, the most recent version of Unity to have been released is Unity 2019.3 (August 28, 2019). The Unity web site also allows the download of its Unity Hub application, which makes it easier for developers to manage installs, licenses, and projects. I, personally, use Unity Hub, but foregoing the Hub for just a Unity installation will not impair your ability to follow along with the text. Next I provide the system requirements listed by Unity on its web site. Check the most recent requirements to confirm your computer’s setup will work with the version of Unity or Unity Hub you download and install.
System Requirements for Unity Development
OS: Windows 7 SP1+, 8, or 10, 64-bit versions only; MacOS 10.12+.
Server versions of Windows and OS X are not tested.
CPU: SSE2 instruction set support.
GPU: Graphics card with DX10 (shader model 4.0) capabilities.
The rest depends primarily on the complexity of your projects.
Additional Platform Development Requirements
iOS: Mac computer running minimum MacOS 10.12.6 and Xcode 9.4 or higher.
Android: Android SDK and Java Development Kit (JDK); IL2CPP scripting back end requires Android Native Development Kit (NDK).
Universal Windows Platform: Windows 10 (64-bit), Visual Studio 2015 with C++ Tools component or later and Windows 10 SDK.
From the Unity web site you can download a free version of the application for beginners. To use VRTK with Unity you must run a version of Unity no earlier than version 2018.
The Code Editor, an Integrated Development Environment
Although Unity is an interface that allows easy, direct creation of VR experiences, it still requires the use of a third-party IDE. As you will learn, Unity allows us to write scripts to perform actions in our Unity program. For Unity to read these scripts, we must provide it with an IDE, or code editor. I like to think of an IDE as a word-processing application like Microsoft Word. An IDE simply provides us a place to write and store our code. Because we write Unity code in a programming language called C#, we cannot use a word processor that only understands human language syntax. A key difference between an IDE and a word processor is the IDE’s inclusion of a compiler. A compiler translates the C# code we write in our IDE into the machine code computers understand.
Visual Studio Code and Unity (ideal for Mac users): https://code.visualstudio.com/docs/other/unity
Visual Studio and Unity:
The download addresses for Visual Studio and VS Code lead to both detailed requirements for your system and installation instructions for use with Unity. These IDEs are not the only options available to you to create VR experiences in Unity. They are, however, the most popular and therefore most helpfully discussed in online forums.
Downloading and Installing Git
Git for Windows:
Git for Mac:
Once you’ve downloaded and set up the necessary applications to begin developing immersive experiences in Unity and VRTK, meet me in the next section where we will test whether or not everything is ready and up to code (get it?).
Setting Up Unity and VRTK
- 1.
Open Unity and create a new 3D project.
- 2.Select the default layout of the Unity application by selecting Main Menu ➤ Window ➤ Layout ➤ Default (Figure 1-1).
- 3.In Unity, navigate to Main Menu ➤ Edit ➤ Project Settings (Figure 1-2).
- 4.In the Project Settings dialog box, navigate to the left-hand tab titled Player (Figure 1-3).
- 5.
Near the bottom of the Player tab, click the XR tab.
- 6.Select the Virtual Reality Supported check box (Figure 1-4).
- Your installation of Unity might show additional parameters for your project’s XR Settings. For example, your installation might show a check box to create support for Vuforia Augmented Reality or other head-mounted displays.
- 7.Navigate to Main Menu ➤ Window ➤ Package Manager (Figure 1-5).
- 8.Near the bottom of the left-hand column in the Unity Package Manager locate the XR Legacy Input Helpers tab (Figure 1-6).
- 9.On the Legacy XR Inputs tab, click Install.
You might see a button to Update or Remove components in your Package Manager window. Whatever your scenario, confirm your project contains the most recent version of Unity’s XR Legacy Input Helpers.
Installing VRTK
- 1.In the default Unity layout the Project window is a hierarchy of your project’s folders at the bottom left of the application. From the Project window navigate to the Assets folder in your operating system’s Finder or File Explorer. A simple way to do this is to right-click the Assets folder in the Unity Project window and select Show in Explorer or Finder (Figure 1-7), depending on whether you use Windows or Mac OS, respectively.
- 2.
From File Explorer, double-click the Assets folder to open it.
- 3.Right-click or Crtl+click in the Assets folder and select Git Bash here (Figure 1-8). If this option does not appear in the shortcut menu, then refer to the resources for installing Git on your operating system.
- 4.
A Git Bash command prompt / terminal window opens.
- 5.
Enter the following text into the Bash and press Enter (Figure 1-9):
- 6.
In the Bash, type cd VRTK and then press Enter.
- 7.
Enter the following text into the Bash and press Enter (Figure 1-10):
- 8.
Return to the Unity project where Unity will import and compile the new files. If you had difficulty executing any of the steps for cloning the VRTK application into your Unity project, then visit the VRTK GitHub page for more detailed instructions (https://github.com/ExtendRealityLtd/VRTK).
- 9.
Finally, if Unity prompts you with a window asking if you’d like to Add VRTK Input Mappings, click the Add Input Mappings button to confirm (Figure 1-11). Because this step will become important for a future exercise in which we connect user actions to events in our VR scene, feel free to select the Do not prompt again check box.
Running the Example Scene
When you are ready to proceed, run the VRTK example scene prepackaged with the application’s files. To do so, continue with the instructions provided by the VRTK GitHub page, which I’ve copied here:
- 1.Open the VRTK/Samples/Farm/Scenes/ExampleScene scene (Figure 1-12).
- 2.
Enable Maximize on Play in the Unity Game view control bar to ensure no performance issues are caused by the Unity Editor overhead.
- 3.
Play the scene in the Unity Editor (Ctrl+P).
- 4.
The scene should automatically play within any Unity-supported XR hardware.
- 5.
Explore the farmyard and enjoy!
Help! I Got Too Many Error Messages!
If, while trying to run the VRTK example scene in Unity, you received a number of error messages, congratulations! You’re officially on your way toward becoming a VR developer. Errors are frustrating, I know. Believe me, I know. But errors are also opportunities to learn more about what is broken, why it is broken, and, most important, how to fix it. An example of one error you received might appear something like this:
XR: OpenVR Error! OpenVR failed initialization: Installation path could not be located!
The solution to this error is to download Steam and SteamVR on your computer, as OpenVR requires both to function. You can read more about Unity’s requirements to run OpenVR in the online Unity documentation at https://docs.unity3d.com/Manual/VRDevices-OpenVR.html.
An example of another error you might have received could appear something like this:
XR: OpenVR Error! Hmd Not Found Presence Failed!
The solution to this error is to confirm that your head-mounted display (HMD) is connected to your computer and that its drivers are up to date.
As many possible errors exist as there are VR systems supported by Unity, at least. MacOS and Windows, too, not to mention the specifics of your personal installation of an operating system, can affect Unity’s performance on your machine. The best path toward solutions, in my experience, is to first reference the official Unity XR resources at https://docs.unity3d.com/Manual/XR.html.
Second, check the documentation for your specific VR system. OpenVR and Oculus, for example, both have Unity integration packages available to download. Developing for mobile VR devices might require installing tools unique to Android. Later in this book, in the chapters addressing user input, we dive more deeply into VR SDKs and integration packages. In addition to the link for Unity’s OpenVR resources included earlier, here are more for Unity’s use with other VR systems:
Oculus: https://docs.unity3d.com/Manual/VRDevices-Oculus.html
Google VR: https://docs.unity3d.com/Manual/googlevr_sdk_overview.html
Windows Mixed Reality: https://docs.unity3d.com/Manual/wmr_sdk_overview.html
Finally, although OpenVR is supported on both Windows and MacOS platforms, running OpenVR on a machine with MacOS has its own hardware requirements:
Unity OpenVR on a macOS requires the Metal graphics and 64bit application target, OpenGL is not supported.
OpenVR supports macOS 10.11.6 or later, but is optimized for macOS 10.13 High Sierra or later. (Unity Manual, https://docs.unity3d.com/Manual/VRDevices-OpenVR.html)
If you received any of the errors I mentioned or others that I did not, please do not be discouraged. I cannot emphasize enough how common feelings of frustration are during this process. If you feel overwhelmed, walk away from the computer and forget about this book for a few hours or even a day. My journey into VR programming has taught me the following lessons.
The Internet is an amazing resource for helping you find others who have experienced the same challenges you face and details of how they overcame them.
The unconscious mind untangles knots without our knowing and may be best left to its own timeline for problem solving.
Endeavor on. Improvement is promised. Knowledge is guaranteed.
While playing VRTK’s example farm scene you will notice a user interface that allows you to toggle between a UnityXRCameraRig and a SimulatedCameraRig. In the next chapter we will learn the difference between these virtual cameras and how to incorporate them into an original scene of our own design.
Summary
If you’ve reached this portion of the chapter, it likely means you’ve successfully set up Unity, Git, and VRTK on your computer. That is no small achievement. I’m sure you experienced challenges, frustration, and in some cases, anger. Congratulations on seeing your way through!
Because VRTK version 4, Unity version 2019, Visual Studio 2019, and VR as a medium, as a whole, are so relatively new in the world of creative development, errors will abound; irritation will mount; and exhaustion will threaten. As a predominantly self-taught VR developer, I know these experiences intimately. However, it is no secret that there has been no greater time in human history to become an engineer of imagination. The tools, although at times buggy, exist, and the creative minds behind their design and execution have done much to pave the road ahead for us well. Yes, things might get bumpy, but the path forward, blazed by pioneers a generation before, is real, and you are on it. By completing this chapter you have proven to yourself that you are ready for the next step.
In this chapter you learned that the fundamental tools for VR development we will need are Unity, an IDE, Git, and VRTK. You learned how to download, install, and set up these tools on your local machine. You cloned a GitHub repository into a machine on your computer, and you ran the VRTK example scene to test whether you set up your tools correctly.
In the next chapter we begin creating a virtual scene of our own design using the tools we have set up on our machines. Because an immersive experience serves as a window into another world, we will begin our first scene with an introduction to virtual cameras in the VR development pipeline.