首页 > 解决方案 > 使用 IL2CPP 在 Visual Studio 中调试 Unity Hololens?

问题描述

我正在运行 Unity 2018.2,并且在使用 IL2CPP 构建 Hololens 项目时,在 Visual Studio 2017 中,当从项目的 C# 脚本调用 Debug.Log 时,我再也看不到任何输出。

我相信我的问题与其他问题有关调试 IL2CPP 代码的最佳方法是什么?.

我已按照这些说明https://docs.unity3d.com/2018.2/Documentation/Manual/ManagedCodeDebugging.html(Visual Studio (Windows)),Hololens 的推荐工具安装(https://docs.microsoft.com/en -us/windows/mixed-reality/install-the-tools)和 Hololens 关于如何在 Unity 中构建项目的说明(https://docs.microsoft.com/en-us/windows/mixed-reality/holograms- 100 )。

使用 IL2CPP 构建时,是否还应该启用其他任何东西来查看 debug.log 输出?

标签: c#unity3dhololensil2cpp

解决方案


我在使用 Unity 2019.1 时也遇到了这个问题。和 Visual Studio 2019。因此,如果有人遇到问题,我设法通过将托管 Unity 调试器附加到运行在 HoloLens 上的应用程序来获得所需的调试行为,如本文所述。然后,我将我的Debug.Log陈述更改为System.Diagnostics.Debug.WriteLine. 基本上,你要做的是

  1. Development Build使用、Script DebuggingWait for managed debugger选项构建您的 Unity 项目。
  2. 确保 HoloLens 通过 WiFi 连接到您的 PC。
  3. 将生成的 VS 解决方案部署到 HoloLens。应用启动后,系统会要求您附加托管调试器。
  4. 通过 Unity 打开一个新的 VS 实例并转到Debug -> Attach Unity Debugger.
  5. 在弹出窗口中选择您的 HoloLens。

然后您可以使用断点,查看输出System.Diagnostics.Debug.WriteLine等。


推荐阅读