使用 IL2CPP 在 Visual Studio 中调试 Unity Hololens?

Unity Hololens debugging in Visual Studio with IL2CPP?

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

我相信我的问题与另一个问题有关

我已按照这些说明进行操作 https://docs.unity3d.com/2018.2/Documentation/Manual/ManagedCodeDebugging.html (Visual Studio (Windows)), the recommended tool installation for Hololens (https://docs.microsoft.com/en-us/windows/mixed-reality/install-the-tools) and the Hololens instructions on how to build a project in Unity (https://docs.microsoft.com/en-us/windows/mixed-reality/holograms-100)。

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

您实际上不需要附加调试器来查看 Debug.Log 调用的输出。所有这些输出都将转到 player log.

您可能还想尝试 Debug.LogError,当您构建开发播放器时,它将在播放器的屏幕 window 中显示错误消息。

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

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

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