Search Unity

Bug VS 2022 many break points not hit

Discussion in 'Code Editors & IDEs' started by andyz, Sep 28, 2022.

  1. andyz

    andyz

    Joined:
    Jan 5, 2010
    Posts:
    2,269
    I have started seeing debugging almost stop working with VS 2022 (Unity 2019 LTS).
    It will break on some points and not others (stepping through the code may go past such points multiple times!).
    Probably a visual studio issue more than Unity, but anyone see this?

    Updating VS and regenerating the project files seems to have fixed for now - but the connections between Unity and VS 2022 seem pretty flaky at present. The number of times I have had to regenerate project files...
     
  2. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    5,892
    Clean and rebuild solution might help. This could be because the code and the built assemblies are out of sync and VS debugger is stepping through code that's not up to date with the assembly being executed.

    And make sure you're not trying to debug a release configuration, since due to code optimizations stepping through code will lead to that behaviour, with some lines skipped and methods not being called (seemingly - the code still works, it just doesn't match the source because the assembly runs optimized versions of the code).
     
  3. BrokenAardvark

    BrokenAardvark

    Joined:
    Jul 14, 2022
    Posts:
    1
    It seems like debugging in VS2022 doesn't really work. You can get it to work if you close both VS and the project and restart. But it will only work once or twice then you have to do it all again. Most of the time when you start the debugger Unity will lock up completely, then when you try to stop the debugger, it will be also be locked up. Seems like they need to spend some time on this as it is mostly useless.
     
  4. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    5,892
    With "they" you mean Microsoft and no, they won't. If you want a better IDE that actually takes good care of supporting fringe dev environments like, for instance, Unity or Unreal, you should look into Rider.

    Also, there's things that can break debugging. Building release configurations for instance, or trying to debug Burst compiled jobs (=> disable Burst for debugging).
     
  5. andyz

    andyz

    Joined:
    Jan 5, 2010
    Posts:
    2,269
    Yeah, it is working almost all of the time for me now. Go to Unity External Tools and Regenerate project files.
    And BTW it is an extremely good IDE which will guess what you are typing and suggest correctly a lot of the time for super quick line completion, as well as all the other normal intellisense and formatting rules (free for community).
    Rider was stuffed full of features last time I tried it, but unless you make use of them all it may not be worth the price, company setup depending.
     
  6. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    5,892
    Rider has, I would say, superior Intellisense. In VS I could not work without having Visual Assist X installed primarily because it enhanced VS Intellisense by several factors.

    The tight integration of Rider with Unity alone is worth it btw. Does VS support recognizing Unity event methods such as Update() by now? Or is it still saying "this method isn't called from anywhere"? Does it show the current Inspector value of a [SerializeField] or public field right next to the variable in the source file? Ever went into PlayMode, wondering why the change you made wasn't applied, only to realize you forgot to save that source file? Does VS hint that you should rather be using this Unity method over the one you typed in, because that one is slower?

    There's a ton of such gems in Rider you don't even have to know about, that are just there and help a lot. ;)

    DISCLAIMER: by this point I should get paid by JetBrains, really! Alas, I am not. :D