Search code examples
c#visual-studiounity-game-engineuwphololens

How to debug a unity c# project on hololens


I have developed an application for hololens with Unity that uses the Hololens' depth camera. I built it with il2cpp scripting backend and it runs well on the Hololens when I launch it from Visual Studio 2017 (community). But I want to be able to debug the app (and have the output in visual studio console) while it is running on the Hololens (because I need the camera frame to be received to see how it works).

Moreover, I want to be able to set breakpoints in my .cs scripts files in my #UWP script parts.

I have been searching for a long time on Microsoft documentation and didn't find the specific answers I was looking for.


Solution

  • I found the answer to my problem!

    In order to debug c# code directly running on the Hololens, I did as follow:

    • In Unity :
      • Build Setting -> Player settings -> Other settings -> Scripting backend = .NET
      • Build Settings :
        • Build configuration Debug
        • check Copy reference
        • check Unity c# project
        • check development build
      • Then you can build
    • In Visual Studio 2017
      • Debug - x86 - Device (or remote machine)
      • If needed : In Solution Explorer -> For each solution -> alt+Enter -> Under Build tab check Allow unsafe code

    Then you can set your break points where ever you want !

    Hope this helps