Building and running your project
It's always a good idea to actually build and run your project as early as possible in your VR development projects. A good first time to try is once things are set up. Then, you can continue to iterate the develop, build, run, and test cycle frequently throughout development. I'll remind you of this as we develop our projects.
So far, you have set the target platform for your build, for example, as standalone Windows or Android. You've installed the XR packages and SDK required for your device. Finally, you've set up an XR camera rig in the scene using the XR Interaction Toolkit. Before you can build, you may also need to configure additional player settings.
Configuring the player settings
There are a wide variety of Player Settings you may need to configure, depending on your target platform.These control the runtime player that is deployed on the target platform and runs your Unity project. These settings include GPU rendering settings, scripting compiler configuration, and optimizations.
It is a good idea to get familiar with these settings as soon as possible. With each new project, for example, you should set Company Name (defaults to DefaultCompany) and Project Name (defaults to the name provided when you created the project in Unity Hub). Android projects require a Package Name (for example, com.[companyname].[projectname]).
I will provide the details of the settings required per platform/device in the corresponding topics later in this chapter. We will adjust them occasionally in the projects throughout this book. Some settings are required for any build to be run. Others are only needed to be configured when you're preparing to publish to a store. These settings are organized into panels, including Icons, Resolution And Presentation, and perhaps the most important catch-all (modestly named), Other Settings. Explanations can be found in the Unity Manual at https://docs.unity3d.com/Manual/class-PlayerSettings.html.
Building, running, and testing your VR project
Depending on your target device, you may have a few more things to set up before you can build and run. These will be addressed in the device-specific topics that follow in this chapter. Then, when you're ready, simply chooseFile | Build And Run(or use theBuild And Runbutton in theBuild Settingsbox).
The scene or scenes you can build are specified in the Build Setting dialog box's Scenes in Build list, as shown in the following screenshot. To add the current open scene, pressAdd Open Scenes. Alternatively, you can drag and drop a scene from theProjectAssets folder into the list. In multi-scene projects, the first one in the list will be the initial default scene that's loaded when your application starts; other scenes can be loaded via C# scripts by callingSceneManager.LoadScene (for scripting examples, see https://docs.unity3d.com/ScriptReference/SceneManagement.SceneManager.LoadScene.html):
When it's time to Build And Run, you'll be prompted to specify a folder for the build files. I recommend a folder namedBuilds/ in the root of your project.
The following screenshot shows the built app running in VR with the default laser raycast hands:
The rest of this chapter will continue to set up Unity and your development system software for the specific platform and device you plan to target. Please skip to the specific section that is relevant to you.