2

With Unity doing away with the .NET scripting backend we have been using the IL2CPP scripting backend so we can get used to it. We have having a very hard time debugging c++ code as the code files created do not use the same method names from the .NET code. More specifically we are developing for the Hololens emulator.

I heard that Unity is putting out some sort of debugger that will let you debug managed .NET c# code at runtime even when you use the IL2CPP scripting backend, does anyone know if that is true and, if so, when that will be coming out. Is anyone doing anything to make this debugging any easier that we may not be thinking of?

slaphshot33324
  • 618
  • 1
  • 8
  • 23
  • https://docs.unity3d.com/Manual/windowsstore-debugging-il2cpp.html – derHugo Oct 16 '18 at 21:17
  • Thanks @derHugo, this is how we've been debugging so far but it's a pain when you're not familiar with cpp (been many years since college cpp courses, lol). – slaphshot33324 Oct 17 '18 at 13:20

1 Answers1

5

Starting in Unity 2018.2, Unity supports debugging of managed code in C# with the IL2CPP scripting backend. The debugging experience is the same as with the Mono scripting backend. On Windows, you will need Visual Studio with the Visual Studio Tools for Unity extension installed.

You can see the managed debugger documentation here: https://docs.unity3d.com/2018.2/Documentation/Manual/ManagedCodeDebugging.html

Josh Peterson
  • 2,299
  • 19
  • 21
  • Thanks, this is helpful. As mentioned we are developing for the Hololens using the emulator and that device is not covered in the documentation you sent. I was able to attach to the Hololens via Visual Studio but I did not see a way to pull up code that was running and insert a breakpoint. This isn't covered in the documentation either, only how to attach the debugger. Once the debugger is attached how do you pull up code that is running and set a breakpoint? – slaphshot33324 Oct 17 '18 at 13:27
  • Try to use the Visual Studio project generated by Unity. It should have the code ready to go and be debugged. – Josh Peterson Oct 17 '18 at 15:52
  • I'm already doing that but the code in the Visual Studio project generated is c++ code. My goal is to debug the c# code at runtime while the c++ code is running on the Hololens emulator. Is that even possible or am I missing what you're saying that Unity supports debugging of managed code in C# with the IL2CPP scripting backend? – slaphshot33324 Oct 17 '18 at 16:04
  • 1
    No, that is entirely possible.I forgot that the Hololens build generates _two_ Visual Studio projects, one with the C# code and one with the generated C++ code. Before you build a Hololens player in the Unity editor, find any C# script in the project and double-click on it from the Unity editor "Project" tab. That should open the C# code in Visual Studio that you need. We can discuss more in-depth on the Unity forums if you would like to. – Josh Peterson Oct 17 '18 at 18:23
  • You should change your question to what you just commented, it reads as a different question – pale bone Oct 20 '18 at 06:15