Unity2020.3 LTS develops Hololens2 MR applications
提示:作者使用的是 Unity 2020.3.34f1 LTS (Unity2020.3 的其他版本也做了测试,OpenXR 要求使用 2020.3.8 LTS 或更高版本),MRTK2.8.2
Article directory
foreword
unity开发HoloLens2必要条件:
- Install the latest version of Windows 10 or 11 . Enable developer mode on your PC via Settings > Update & Security > For Developers. "N" editions of Windows do not support Windows Mixed Reality immersive (VR) headsets.
- Installing Visual studio 2019 or 2022 make sure to install the following workloads:
● .NET desktop development
● Desktop development using C++
● Universal Windows Platform (UWP) development
● Game development using Unity
In the UWP workload , make sure to include the following components so that Install:
● Windows 10 SDK version 10.0.19041.0 or 10.0.18362.0, or Windows 11 SDK
● USB device connection (required for HoloLens deployment/debugging via USB)
● C++ (v142) Universal Windows Platform tools - Install Mixed Reality Feature Tool.exe Microsoft official download center download address
1. Start operation steps
1. Create a new Unity project
Start the hub -> Create a new unity 3dcore project -> Switch to Universal Windows Platform
2. Import MRTK package
-
Open Mixed Reality Feature Tool.exe
-
Select project path
-
Select the necessary functions (the example plug-in package can also be installed, suitable for beginners)
3. Configure scene packaging test
-
After Unity imports the package, a warning will appear asking if you want to enable the backend by restarting the editor. Select "Yes".
If there is no manually configurable item, follow the prompts step by step. -
From the menu bar, choose Mixed Reality > Toolkit > Add to Scene and Configure….
-
Add interaction model (a block), add 2 scripts (ObjectManipulator, NearInteractionGrabbable)
-
Input Simulation Unity In-Editor Input Simulation
You can use Unity's in-editor input simulation feature to test holographic object behavior.
Change the view in the scene:
To move the camera forward/left/backward/right, press W/A/S/D keys.
To move the camera vertically, press the Q and E keys.
To rotate the camera, right-click, and drag.
Simulated Hand Input:
To enable simulated right hand, press and hold the space bar. To remove the hand, release the spacebar.
To enable left-handed simulation, hold down the left Shift key. To remove the hand, release the key.
To move the left or right hand around the scene, move the mouse.
To move the hand forward or backward, scroll the mouse wheel.
To simulate a pinch gesture, click the left mouse button.
To rotate the hand, hold down Spacebar + CTRL (right hand) or Left Shift + CTRL (left hand), then move the mouse.
Persistent Hands
To enable your hand and keep it on screen without continuing to hold a key, press T (left hand) or Y (right hand). Press these keys again to remove the hand. -
Packaging test
can be easily packaged to Hololens on unity, as shown in the figure
-
Pack onto the device and move the cubes by hand. can
Summarize
The above is what I want to talk about today. This article only briefly introduces the development of Hololens2 MR applications with Unity. If you have any questions, please comment, and a demo will be released later for reference.