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
- Download Unity Hub first
- Enter the Unity Hub and download the relevant version of Unity2020 LTS
2. Configure MRTK
After installing Unity install these two:
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:
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:
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:
4. Update project
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
6. Rename App (Optional)
Edit > Project Settings… to open Project Settings.
'Package name' is to name the output app, which is not used yet
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.
8. Connect Hololens via WiFi in VS
Open the sln project, configure the development environment,
enter the IP address of the glasses in the properties,
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
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