操作环境
Unity 2021.3.21f1
MRTK 2.8.2 + OpenXR
VS 2022
项目设置部署可参考一下内容
[1]. https://learn.microsoft.com/zh-cn/training/modules/learn-mrtk-tutorials/1-3-exercise-configure-unity-for-windows-mixed-reality?ns-enrollment-type=learningpath&ns-enrollment-id=learn.azure.beginner-hololens-2-tutorials
[2].https://learn.microsoft.com/zh-cn/windows/mixed-reality/develop/advanced-concepts/using-visual-studio?tabs=hl2
出现的问题
官方教程和网上众多的低版本教程中使用的Unity2020不会出现该问题。
在Unity2021中准确按照官方教程进行打包部署后,在真机尝试打开运行程序时一直处在加载界面后直接崩溃退出(官方解释为当检测到手时,HL2应用程序崩溃)。
通过调试后发现出现一下错误,显示为栈溢出情况(实际报错不止该条,但同样为溢出问题,同时修改修改Visual Stdio Stack 默认设置中堆栈保留和提交大小后仍不能解决问题)
Unhandled exception at 0x00007FF8D170C1F7 (GameAssembly.dll) in xxx.exe: 0xC00000FD: Stack overflow (parameters: 0x0000000000000001, 0x000000B984F03000).
解决方法
官方解决方法
找到项目的Packages/manifest.json文件
打开后增加在里面增加包com.unity.inputsystem,版本为1.5.1或以上
参考文献
[1]. https://forum.unity.com/threads/unhandled-exception-when-debugging-app-to-hololens-2-emulator.1404943/
[2]. https://learn.microsoft.com/en-us/windows/mixed-reality/develop/unity/known-issues#resolved-blocking-issues