Exercise - Import and configure resources
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.
Download the latest version of the Mixed Reality Feature Tool from the Microsoft Download Center.
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.
In the unzipped folder, navigate to the executable file MixedRealityFeatureTool.exe and then use it to launch the Mixed Reality Feature Tool.
In the Mixed Reality Feature Tool, select Start.
Select the Browse button (it's the "three-dot" button in the image below), then navigate to your project, and then open it.
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.
Select Discover Features.
Note: You may need to wait a few seconds while the Tool refreshes the packages from the feeds.
On the Discover Features page, note that there is a list of six package groups.
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.
Click the "+" button to the left of Platform Support (0 of 5) and then select the latest version of Mixed Reality OpenXR Plugin.
After you've made your selection(s), click Get Features.
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.
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.
When you're ready to move on, select Import. On the Review and Approve page, you can review information about the packages.
Select Approve.
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
After Unity has imported the packages, a warning appears asking if you want to enable the backends by restarting the editor. Select Yes.
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:
Select Unity OpenXR Plugin to enable XR Plugin Management and add the Unity OpenXR Plugin to your project.
On the Welcome to MRTK! screen, select Show XR Plug-In Management Settings.
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.
Ensure that Initialize XR on Startup is selected, and then, under Plugin Providers, click Open XR.
The OpenXR Plugin loads, and then two items appear underneath OpenXR. Select the first one, Microsoft HoloLens feature group.
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.
In the OpenXR Project Validation window, there are several issues listed. Select the Fix All button.
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.
Underneath Interaction Profiles, note the plus sign (+) button.
Click the button three times, each time choosing a different profile:
Eye Gaze Interaction Profile
Microsoft Hand Interaction Profile
Microsoft Motion Controller Profile
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.
In the Project Settings window under OpenXR Feature Groups, ensure that the following are selected:
Microsoft HoloLens
Hand Tracking
Motion Controller Model
Click the Depth Submission Mode drop down and then select Depth 16 Bit.
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.
Close the Project Settings window.
In the MRTK Project Configurator window, select Apply Settings.
Select Next and then Apply.
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
After Unity restarts, in the menu bar, select Edit > Project Settings....
In the Project Settings window's left-side column, select Player.
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.
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.
Click the Publishing Settings drop down, and then in the Package name field, enter a suitable name--for example, MRTK-Tutorials-Getting-Started:
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.
Close the Project Settings window.
Create the scene and configure MRTK
In the menu bar, select File > New Scene.
In the New Scene window select Basic (Built-in) and then click Create.
In the menu bar, select Mixed Reality > Toolkit > Add to Scene and Configure....
The Mixed Reality Toolkit settings appear 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.
In the Inspector, verify that the profile drop down displays DefaultMixedRealityToolkitConfigurationProfile:
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.
In the menu bar, select File > Save As....
Navigate to the Assets > Scenes folder, then name your project, and then save your project.
Trebate pomoć? Pogledajte naš vodič za rješavanje problema ili pošaljite željene povratne informacije prijavljivanjem problema.