visual-studiounity-game-enginebreakpoints

Visual Studio Moving Breakpoints (Unity)


I'm developing with Unity, and whenever I add code to a script and save it, Visual Studio moves the breakpoints I have set that are below the new code. It seems that the number of lines I add moves the breakpoints that many lines up. (Breakpoints will also move down if I delete code) It seems they get moved after Unity recompiles the changes I made. This might be key?

So a breakpoint on line 220 will move up to 218 if I add two lines of code at line 216.

I've been dealing with this issue for a while. I've tried searching for solutions but have come up with null in the past. This has persisted through several Unity and Visual Studio Community updates. I have the latest version of each.


Solution

  • After I add code and it moves my breakpoints, I can hit Stop Debugging, Reattach to Unity and my breakpoints go back to where they were.

    I do not know of another solution to this. It's got something to do with Unity recompiling code and getting the breakpoints desynchronized.