I would like to debug initialization of my game from Visual Studio as a build (not in the editor).
I cannot find a way to make visual studio automatically attach to the build when it starts.
I tried googling and found a plugin called Entrain Attach, but it didn’t work. When I added breakpoints with that plugin it just said “no symbols found” when I hovered over the break point and wasn’t stopping at them.
Any ideas? Would be great if this feature was build into the Unity/Visual Studio plugin.
In my case I’m trying to use it to test data loading in the initialization of my project (getting settings from a scriptable object loaded onto a resources file). I solved the problem already actually, but it was just through guess work.
Still wouldn’t it be awesome if you could just hit build and play and the debugger attached automatically and you didn’t have to go through the extra 5 clicks to attach?
It may not seem significant but it is when you do it a thousand times a day, Many things in Unity can only be tested in builds.
There is already an “auto attach profiler” option in build settings that does a similar thing, why not “auto attach debugger” as well.
I personally think that “auto attach” profiler is also not needed, but that’s just me… Whenever i need to attach something i just do it myself.
I think that scenarios such as the one you describe can be (usually) tested by adding another “dummy” scene before your first actual game scene. This scene will basically block until a debugger is attached, and then move on to the real first game scene. In this way you can debug your game loading flow.
This can be trickier if you need to debug stuff that is executed automatically (e.g: InitializeOnLoad stuff), but then again - the debugging engine on players (when running on a device) is usually initialized very early on, leaving you enough time to attach a debugger before anything gets executed.