Hololens 2 + Unity environment configuration

0. Development environment:

Win10
Unity 2020.3.31f1c1
VS2019

Official development documents:

https://docs.microsoft.com/en-us/learn/modules/learn-mrtk-tutorials/1-1-introduction

1. Select the appropriate Unity version and download it

https://docs.microsoft.com/en-us/windows/mixed-reality/develop/unity/choosing-unity-version

  1. Download Unity Hub first
  2. Enter the Unity Hub and download the relevant version of Unity2020 LTS

2. Configure MRTK

After installing Unity install these two:

  1. .NET 5.0 runtime
  2. MRFT

Starting from MRTK2.6, Microsoft provides the Mixed Reality Feature Tool (MRFT) tool, which can manage MRTK visually.
https://docs.microsoft.com/en-us/windows/mixed-reality/develop/unity/welcome-to-mr-feature-tool

After running MRFT, select these 4 features:insert image description here

3. OpenXR configuration

After installing the above components, open unity and it will automatically update. After the update, it should appear XR 插件管理设置, and then click here:
insert image description here
For the subsequent series of operations, refer to removing the exclamation mark next to the OpenXR selection box.

HoloLens2 road - Unity2020.3+MRTK2.7 configuration_DavidWang-CSDN blog
https://blog.csdn.net/yolon3000/article/details/121776416

It should end up like this:
insert image description here

4. Update project

insert image description here

5. Configure MRTK in Unity

In the Hierarchy window, select the MixedRealityToolkit game object, and then in the Inspector window, select the main configuration file under the MixedRealityToolkit component as DefaultHoloLens2ConfigurationProfile
insert image description here

6. Rename App (Optional)

Edit > Project Settings… to open Project Settings.
'Package name' is to name the output app, which is not used yet
insert image description here

7. Export Unity project to VS

It is convenient for programmers to manually modify some development codes.
File->BuildSettings, according to the default settings in the figure below, Build to an empty folder.
insert image description here

8. Connect Hololens via WiFi in VS

Open the sln project, configure the development environment,
insert image description here
enter the IP address of the glasses in the properties,
insert image description here
and run the program, a pop-up will pop up to ask you to enter a PIN code. Note that this PIN is not the PIN you turn on. You need to pop up a PIN code in the glasses .设置->更新与安全->开发者选项->配对

9. Connect Hololens via WiFi in Unity

insert image description here
Then enter the ip address of the glasses, and click Enable Holographics Remoting for Play Mode. Then run the unity program. . .

connection succeeded! The environment configuration is complete!

If you want to turn off the performance analysis bar displayed by Unity:
select MixedRealityToolkit in the panel, clone the configuration file of HoloLens 2, select "Diagnostics" to clone again, and disable the system diagnosis to disable the performance analysis window.

If you run it directly, a gridded spatial map will appear. If you want to remove the empty grid, you can do this:

References

https://blog.csdn.net/shedipai0528/article/details/123377096
https://blog.csdn.net/yolon3000/article/details/121776416

Guess you like

Origin blog.csdn.net/qq_41598072/article/details/123685738