Unity Hololens debugging in Visual Studio with IL2CPP?

1.7k views Asked by At

I am running Unity 2018.2 and when building my Hololens project with IL2CPP, in Visual Studio 2017 I can no longer see any output when Debug.Log is called from my project's C# scripts.

I believe my question is related to this other question What is the best way to debug IL2CPP code?.

I have followed these instructions https://docs.unity3d.com/2018.2/Documentation/Manual/ManagedCodeDebugging.html (Visual Studio (Windows)), the recommended tool installation for Hololens (https://learn.microsoft.com/en-us/windows/mixed-reality/install-the-tools) and the Hololens instructions on how to build a project in Unity (https://learn.microsoft.com/en-us/windows/mixed-reality/holograms-100).

Is there anything else that should be enabled to see the debug.log outputs when building with IL2CPP?

2

There are 2 answers

0
chrissi_gsa On BEST ANSWER

I also had this issue using Unity 2019.1. and Visual Studio 2019. So in case anybody has troubles with that, I managed to get my desired debugging behavior by attaching a managed Unity Debugger to the App running on the HoloLens as described in this post. Then, I changed my Debug.Log statements to System.Diagnostics.Debug.WriteLine. Basically, what you have to do is

  1. Build your Unity Project with Development Build, Script Debugging and Wait for managed debugger options.
  2. Make sure the HoloLens is connected to your PC via WiFi.
  3. Deploy the generated VS solution to your HoloLens. Once the App starts, you will be asked to attach a managed debugger.
  4. Open a new VS instance via Unity and go to Debug -> Attach Unity Debugger.
  5. Select your HoloLens in the Popup.

You can then use Breakpoints, see outputs of System.Diagnostics.Debug.WriteLine etc.

2
Josh Peterson On

You don't actually need a debugger attached to see the output of Debug.Log calls. All of that output will go to the player log.

You may also want to try Debug.LogError, which will display the error message in an on-screen window in the player, when you have made a development player build.