Exercise - Import and configure resources

Completed

Import the MRTK Unity foundation package

To import the Mixed Reality Toolkit into your project we'll use the Mixed Reality Feature Tool, which allows developers to discover, update, and import feature packages. You can search packages by name or category, see their dependencies, and view proposed changes to your project's manifest file before importing.

  1. Download the latest version of the Mixed Reality Feature Tool from the Microsoft Download Center.

  2. After the download finishes, unzip the file and save it to your desktop.

    Note

    Before you can run the Mixed Reality Feature Tool, you must install the .NET 5.0 runtime. Though this version is no longer supported, it is the correct version for this exercise.

  3. In the unzipped folder, navigate to the executable file MixedRealityFeatureTool.exe and then use it to launch the Mixed Reality Feature Tool.

    Screenshot of Opening MixedRealityFeatureTool.

  1. In the Mixed Reality Feature Tool, select Start.

    Screenshot of the Mixed Reality Feature Tool opening screen.

  2. Select the Browse button (it's the "three-dot" button in the image below), then navigate to your project, and then open it.

    Open your project

    Note

    The Project Path box in the Tool must contain some value, so it inserts a backslash ("_") by default.

    After you select a folder, the Tool checks to ensure that it's a valid Unity project folder.

    Screenshot of the Mixed Reality feature Tool Project Path screen.

  3. Select Discover Features.

    Note: You may need to wait a few seconds while the Tool refreshes the packages from the feeds.

  4. On the Discover Features page, note that there is a list of six package groups.

    The main groups of packages in the Mixed Reality Feature Tool

  5. Click the "+" button to the left of Mixed Reality Toolkit (0 of 10) and then select the latest version of Mixed Reality Toolkit Foundation.

    Note

    The Mixed Reality Toolkit Foundation package is the only package that must be imported and configured in order to use MRTK with your project. This package includes the core components required to create a mixed reality application.

  6. Click the "+" button to the left of Platform Support (0 of 5) and then select the latest version of Mixed Reality OpenXR Plugin.

    Screenshot of package selections in the Mixed Reality Feature Tool.

  7. After you've made your selection(s), click Get Features.

  8. Select Validate to validate the packages you selected. You should see a dialog that says No validation issues were detected. When you do, click OK.

  9. On the Import Features page, the left-side column, Features, displays the packages you just selected. The right-side column, Required dependencies, displays any dependencies. You can click the Details link for any of these items to learn more about them.

  10. When you're ready to move on, select Import. On the Review and Approve page, you can review information about the packages.

  11. Select Approve.

  12. Return to the Unity Editor and click a blank area in the UI. You'll see a progress bar showing you that your packages are being imported.

Configure the Unity project

  1. After Unity has imported the packages, a warning appears asking if you want to enable the backends by restarting the editor. Select Yes.

    Screenshot of Unity Restart Option.

  2. The MRTK Project Configurator should appear. If it doesn't, open it manually: on the menu bar, select Mixed Reality > Toolkit > Utilities > Configure Project for MRTK:

    Screenshot of the menu bar command for opening the MRTK Configurator.

  3. Select Unity OpenXR Plugin to enable XR Plugin Management and add the Unity OpenXR Plugin to your project.

    Screenshot of MRTK project configurator window with OpenXR selected.

  4. On the Welcome to MRTK! screen, select Show XR Plug-In Management Settings.

    Screenshot of the Show XR Plug-In Management Settings button.

  5. The Project Settings window opens. Ensure that you're on the XR Plug-in Management page with the Universal Windows Platform settings (Windows logo tab) displayed.

    Screenshot of the Project Settings Window open to the XR Plugin Management Page and Universal Windows Platform tab.

  6. Ensure that Initialize XR on Startup is selected, and then, under Plugin Providers, click Open XR.

    Screenshot of Project Settings Window 3.

  7. The OpenXR Plugin loads, and then two items appear underneath OpenXR. Select the first one, Microsoft HoloLens feature group.

  8. Note that there's now a yellow warning triangle next to OpenXR. Hover your cursor over the triangle, then read the message in the popup, and then select the triangle.

    Screenshot of warning about incompatible settings.

  9. In the OpenXR Project Validation window, there are several issues listed. Select the Fix All button.

    Screenshot of the Fix All button in the OpenXR Project Validation window.

  10. One issue remains and tells you that you must add at least one interaction profile. To do so, click Edit. This takes you to the settings for the OpenXR plugin in the Project Settings window.

    Screenshot of the Project Settings window with the OpenXR settings displayed.

  11. Underneath Interaction Profiles, note the plus sign (+) button.

    Screenshot of the Add Interaction Profile button.

  12. Click the button three times, each time choosing a different profile:

    Eye Gaze Interaction Profile

    Microsoft Hand Interaction Profile

    Microsoft Motion Controller Profile

    Screenshot of interaction profiles that should be added.

    If the Eye Gaze Interaction Profile, or any other profile, appears with a yellow triangle next to it, select the triangle, and then in the OpenXR Project Validation window, click the Fix button. When you're finished, close the OpenXR Project Validation window.

    Screenshot of the Fix button for the Eye Gaze interaction profile.

  13. In the Project Settings window under OpenXR Feature Groups, ensure that the following are selected:

    Microsoft HoloLens

    Hand Tracking

    Motion Controller Model

    Screenshot of selected features for OpenXR.

  14. Click the Depth Submission Mode drop down and then select Depth 16 Bit.

    Screenshot of Depth 16 Bit selected for Depth Submission Mode.

    Tip

    Reducing the Depth Format to 16-bit is optional, but it may improve graphics performance in your project. To learn more, see Depth buffer sharing (HoloLens).

    Note

    The Render Mode setting, located just above Depth Submission Mode, is set by default to Single Pass Instanced. In mixed reality apps, the scene is rendered twice: once for each eye. The result is "stereoscopic vision." This doubles the amount of necessary computing, so it's important to select the most efficient rendering path in Unity to save on both CPU and GPU time. Single pass instanced rendering is the best choice here--we recommend that you enable it by default for every project. To learn more about this, see the Unity documentation.

  15. Close the Project Settings window.

  16. In the MRTK Project Configurator window, select Apply Settings.

    Screenshot of MRTK Project Configurator with the Apply Settings button.

  17. Select Next and then Apply.

  18. Unity must restart in order for the configuration to take effect. When prompted, select Apply to restart the Unity editor.

Configure project settings for OpenXR

  1. After Unity restarts, in the menu bar, select Edit > Project Settings....

  2. In the Project Settings window's left-side column, select Player.

  3. Note that in the Player window, the Product Name is "MRTK Tutorial." This is taken from your project name and will be the name displayed in the HoloLens Start menu.

    Screenshot of Unity Publishing Settings with the Project Name box filled in.

    Tip

    To make the app easier to locate during development, add an underscore in front of the name to sort it to the top of any list.

  4. Click the Publishing Settings drop down, and then in the Package name field, enter a suitable name--for example, MRTK-Tutorials-Getting-Started:

    Screenshot of Unity Publishing Settings with the package name box filled in.

    Note

    The package name is the unique identifier for the app. If you want to avoid overwriting previously installed versions of the app with the same name, you should change this identifier before deploying the app.

  5. Close the Project Settings window.

Create the scene and configure MRTK

  1. In the menu bar, select File > New Scene.

  2. In the New Scene window select Basic (Built-in) and then click Create.

  3. In the menu bar, select Mixed Reality > Toolkit > Add to Scene and Configure....

    The Mixed Reality Toolkit settings appear in the Inspector.

    Screenshot of the Mixed Reality Toolkit in the Inspector.

    After MRTK is added to the scene and configured, two new objects are added to the Hierarchy window:

    MixedRealityToolkit

    MixedRealityPlayspace

    The MixedRealityToolkit object contains the Toolkit itself. The MixedRealityPlayspace object ensures that the headset/controllers and other required systems are managed correctly in the scene.

    The Main Camera object becomes a child to the MixedRealityPlayspace object. This allows the play space to manage the camera simultaneously with the SDKs.

    Screenshot of new objects in the Hierarchy after MRTK is added.

  4. In the Inspector, verify that the profile drop down displays DefaultMixedRealityToolkitConfigurationProfile:

    Screenshot of the Mixed Reality Toolkit in the Inspector with the DefaultMixedRealityToolkitConfiguration profile displayed.

    Note

    One of the main ways that you can configure MRTK is by selecting a profile made available through the Foundation package. Profiles configure the behavior of MRTK core components. When MRTK is added to the scene, "DefaultMixedRealityToolkitConfigurationProfile" is preselected. This profile is for general use--it isn't optimized for any particular use case. MRTK provides additional default profiles that cover most platforms and scenarios that MRTK supports. You may want to choose a profile that's optimized for the specific platform you're using. To learn more about configuration profiles, see the MRTK profile configuration guide.

  5. In the menu bar, select File > Save As....

  6. Navigate to the Assets > Scenes folder, then name your project, and then save your project.