Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

PSA: If your VS Code C# extension stopped working...

Discussion in 'External Tools' started by Incode, Mar 5, 2020.

  1. Incode

    Incode

    Joined:
    Apr 5, 2015
    Posts:
    62
    No problem, just wanted to make sure you were able to keep using VS Code. I completely agree, it's very frustrating that the feedback is usually "file a bug", when the bug is just: open the text editor -> see that it doesn't work.

    The package system was supposed to allow issues like this to be addressed more quickly, but I think it may have fractured Unity's internal communication channels, which is why clarity on these issues is so hard.
     
  2. TheLouise

    TheLouise

    Joined:
    Jun 1, 2017
    Posts:
    5
    I tried everything described here and still nothing, this is driving me crazy! I was with everything on the lastest release (VS Code, C# Extension, .NDK) and decided to reverse things. I'm currently with
    • Unity 2019.3.6f1 Education;
    • VS Code 1.42;
    • C# extension 1.21.12
    • Unity Code Snippets and Unity Snippeds Extensions
    • VS Code Editor 1.1.4 on Unity Package Manager
    I have extensions for HTML, Bootstrap, PHP and Laravel as well, but I don't believe that they are the problem. This is driving me crazy!
     
    swilliams44 likes this.
  3. Incode

    Incode

    Joined:
    Apr 5, 2015
    Posts:
    62
    I would try downgrading to 1.1.3 or upgrading to 1.2.0. There are known issues with 1.1.4.
     
  4. Aaron-Meyers

    Aaron-Meyers

    Joined:
    Dec 8, 2009
    Posts:
    290
    Ugh this is so annoying... I tried @herb_nice's setup with 1.42.1 and C# 1.21.12, but I'm still getting the "Some projects have trouble loading. Please review the output for more details."

    upload_2020-3-26_13-32-49.png

    Not recognizing some core Unity assemblies! I can't get code hinting for any of these UI classes :/

    Any suggestions for fixes?
     
    Radivarig likes this.
  5. v2-Ton-Studios

    v2-Ton-Studios

    Joined:
    Jul 18, 2012
    Posts:
    206
    It's becoming pretty clear this isn't an isolated issue.

    Friendly request for someone from Unity to drop in here and let us know what the plan is. VS Code is a great editor, I prefer it to full Visual Studio and would really like to see some official action / response here. TIA!
     
    ratking and ZoraMikau like this.
  6. ETGgames

    ETGgames

    Joined:
    Jul 10, 2015
    Posts:
    40
    This also fixed it for me, but it's a really temporary solution. At least some update by the unity team would be nice here
     
    Incode and v2-Ton-Studios like this.
  7. Dan-MacDonald

    Dan-MacDonald

    Joined:
    Oct 25, 2013
    Posts:
    17
    Recent omnisharp releases have fixed the performance issues with intellisense. However on Unity 2018 LTS, debugging with VS Code is no longer possible. Debugger attaches and threads appear to pause, but the execution cursor never appears at the breakpoint.
     
  8. Dan-MacDonald

    Dan-MacDonald

    Joined:
    Oct 25, 2013
    Posts:
    17
    Downgrading VS Code to 1.42.1 got my debugger working again. (with downgraded C# and Unity Debugger Extensions)
     
    herb_nice and Incode like this.
  9. Axon92

    Axon92

    Joined:
    Sep 24, 2015
    Posts:
    7
    I've also been having similar issues with VS Code and Unity lately. Downgrading VS Code to 1.42.1 seems to have fixed them. All assemblies are now recognized, debugging works as well.

    My current dev environment is:

    Mac OS 10.14
    Unity 2018.4.19f1
    VS Code 1.42.1
    C# extension 1.21.15
    Debugger for Unity extension 2.7.5

    I also have the latest stable Mono version(6.8.0) and .NET Core 3.1 installed.
     
    Dan-MacDonald and v2-Ton-Studios like this.
  10. Dan-MacDonald

    Dan-MacDonald

    Joined:
    Oct 25, 2013
    Posts:
    17
    Can confirm @Axon92 's setup. I was able to upgrade my Unity Debugger and C# extensions to the versions he mentioned. (which are the current versions) and debugging still works using VS Code 1.42.1
     
  11. Peter5897

    Peter5897

    Joined:
    Jan 4, 2017
    Posts:
    20
    I'm back to running latest and haven't noticed issues so far.

    Unity: 2019.3.0f6
    Vs Code 1.42.3
    C# extension: 1.21.15
    Debugger for Unity extension: 2.7.5
    Visual Studio Code Editor Package: 1.2.0
     
  12. v2-Ton-Studios

    v2-Ton-Studios

    Joined:
    Jul 18, 2012
    Posts:
    206

    Good to know. Did you uninstall everything and then reinstall or just upgrade from older / other versions?
     
  13. Peter5897

    Peter5897

    Joined:
    Jan 4, 2017
    Posts:
    20
    I uninstalled the old C# extension but everything else I just updated in place.
     
    v2-Ton-Studios likes this.
  14. paulbettner

    paulbettner

    Joined:
    Jan 13, 2014
    Posts:
    10
    I really don't want to go through all the uninstalls/upgrades/reinstalls only to find that it still doesn't work... can anyone else confirm that the latest versions Peter5897 mentioned do in fact work now?
     
  15. paulbettner

    paulbettner

    Joined:
    Jan 13, 2014
    Posts:
    10
    Ok, I did it - I updated to all the latest versions like the fearless Peter5897 - and I can CONFIRM that it is working - at least on my machine (a mac).
     
  16. v2-Ton-Studios

    v2-Ton-Studios

    Joined:
    Jul 18, 2012
    Posts:
    206
    Okay... going to try this today and let everyone know... super hopeful this works!
     
    ETGgames likes this.
  17. tcz8

    tcz8

    Joined:
    Aug 20, 2015
    Posts:
    374
    Read for possible fix:

    TLDR in bold

    I've been having the same issues. Also matches with Microsoft renaming Omnisharp's package name.

    The proposed workaround worked for a while but the problem came back. Investigating the issue I found out a vscode add-on kept reinstalling the new version of Omnisharp next to the old one (had 2 versions running). I tried removing the problematic add-on, deleting both Omnisharp versions and reinstalling the workaround version but nothing would fix it.

    Ended up deleting the library folder, all the .csproj files and Saturday night live files (.snl ;)). Close unity before doing any of this. Took forever for unity to regenerate the files on it's first start but its fixed now, hopefully for good.

    I'm running Unity 2018.4.15f1, the latest vscode version and Omnisharp version.

    Fingers crossed.

    UPDATE
    Just upgraded from 2018.4.15f1 to 2018.4.20f1 and it broke again. Had to delete all the files mentioned above and restart once more... it takes HOURS on our project :eek: o_O
     
    Last edited: Apr 2, 2020
  18. Quast

    Quast

    Joined:
    Jul 5, 2015
    Posts:
    521
    For me, is running fine after updated VScode.
     
  19. ETGgames

    ETGgames

    Joined:
    Jul 10, 2015
    Posts:
    40
    How did it go?
     
  20. Incode

    Incode

    Joined:
    Apr 5, 2015
    Posts:
    62
    Not that poster, but I've just tested on all the latest and it is now working for me again.
     
  21. v2-Ton-Studios

    v2-Ton-Studios

    Joined:
    Jul 18, 2012
    Posts:
    206
    I've been neck deep in animation stuff... hope to circle back to this tomorrow... sorry for delay :|.
     
  22. Gary_Thomas128

    Gary_Thomas128

    Joined:
    Mar 3, 2014
    Posts:
    17
    I was having the same issues and tried many of the above recommended steps - not much joy.

    However, I found that if I upgrade the VSCode extension via the Unity Package Manager to 1.2.0 (and no changes to my VSCode install/extensions) it works just like it used to. Simply go to Edit->Preferences->Editor (in Unity) and you'll now have a nice option box for .csproj file production. No need to check anything, just press the 'Regenerate' button and your VSCode will start working again. I tried it with the latest Unity versions - 2019.3.7f1 and 2020.1.0b4, both work as desired. :)

    n.b. creating a new project will bring in the VSCode extension 1.1.4, so you'll need to manually update to 1.2.0 & don't forget the 'Regenerate' button!
     
    Victoralm, saberum and colin_young like this.
  23. v2-Ton-Studios

    v2-Ton-Studios

    Joined:
    Jul 18, 2012
    Posts:
    206
    Is this a typo? Did you mean 1.43.2, rather than 1.42.3? Which I think is the latest? Just wanted to make sure :).
     
  24. v2-Ton-Studios

    v2-Ton-Studios

    Joined:
    Jul 18, 2012
    Posts:
    206
    Just FYI: If you're on Unity 2018, the package manager seems to be under Window > Package Manager.
     
  25. v2-Ton-Studios

    v2-Ton-Studios

    Joined:
    Jul 18, 2012
    Posts:
    206
    I'm probably just being dense... but...

    (1) where do you download this package?
    and (2) how do I check which package I have installed?

    Until things recently broke I've been using VS Code w/o problems and I don't believe I have this package installed. It is definitely not listed in my package manager.

    TIA!
     
  26. Axon92

    Axon92

    Joined:
    Sep 24, 2015
    Posts:
    7
    Which version of Unity are you using? It looks like the package might only be available in Unity 2019. I've noticed that Unity 2018.4 doesn't list a VSCode package in the package manager, but Unity 2019.3 does.

    I'm not sure if there's an easy way to find out which Unity versions are supported by this plugin, the documentation doesn't really say much(https://docs.unity3d.com/Packages/com.unity.ide.vscode@1.2/manual/index.html).
     
  27. v2-Ton-Studios

    v2-Ton-Studios

    Joined:
    Jul 18, 2012
    Posts:
    206

    On 2018 until we ship for stability :|. Maybe it's not available?

    Does that means I'm stuck w a broken debugger? I might just go use Visual Studio community and move on with my life :).

    Appreciate the help here.
     
  28. Acazied

    Acazied

    Joined:
    Mar 2, 2016
    Posts:
    47
    Thanks works perfectly
     
  29. tcz8

    tcz8

    Joined:
    Aug 20, 2015
    Posts:
    374
    Same problem here... did you figure it out?
     
  30. AppShard

    AppShard

    Joined:
    Apr 21, 2020
    Posts:
    1
    Be sure to have the .NET Framework 4.7.1 Developer Pack installed on your PC. That was my hang-up.
     
  31. herb_nice

    herb_nice

    Joined:
    May 4, 2017
    Posts:
    168
    unpopular opinion: updating blindly and running the latest bleeding-edge anything just to have the latest is a bad idea. best practice is to stick on versions of stuff that is known to work. nobody is testing your scenario before they push a release.
     
    MegamaDev likes this.
  32. Peter5897

    Peter5897

    Joined:
    Jan 4, 2017
    Posts:
    20
    JoeRobich, the guy who works on the team that decided to change the C# extensions package name and break this stuff, tested it. https://github.com/Unity-Technologies/vscode-unity-debug/pull/152

    If we're throwing out best practices, I'd say it's probably best not to change the name of a package that has 7.2 million downloads and dependencies throughout the C# ecosystem. Especially when the editor that your company ships automatically updates packages by default which knowingly puts folks in to a broken state, I'm guessing you'd agree.
     
    Incode and herb_nice like this.
  33. Radivarig

    Radivarig

    Joined:
    May 15, 2013
    Posts:
    31
  34. Radivarig

    Radivarig

    Joined:
    May 15, 2013
    Posts:
    31
    But I still have the same missing namespaces issue like Aaron-Meyers mentioned, for both vscode 1.42.1 and 1.44.1 and 1.21.12 and 1.21.17 c#
     
  35. Gl3nn1972

    Gl3nn1972

    Joined:
    Oct 10, 2018
    Posts:
    1
    Thank you
     
  36. llorens-marti

    llorens-marti

    Joined:
    Apr 30, 2013
    Posts:
    6
    Hi,

    Not sure if it will help, but on StackOverflow I saw something that solved for me: https://stackoverflow.com/a/60763699

    Basically you need to add this entry:


    Code (JavaScript):
    1. <Reference Include="UnityEngine.UI">
    2. <HintPath>Library/ScriptAssemblies/UnityEngine.UI.dll</HintPath>
    3. </Reference>

    on the Assembly-CSharp.csproj file at the root of Unity project.

    Versionsof the software I have:
    VSCode: 1.44.2
    OmniSharp: 1.21.17
     
  37. SirIntruder

    SirIntruder

    Joined:
    Aug 16, 2013
    Posts:
    43
    Any change you make to .csproj files manually will be overwritten by Unity, at whenever Unity feels like.

    Reason why this line was missing was because Unity code that updates .csproj files has a bug. Fix for this is to update Unity's package that is the source of the bug (update vscode-editor package from 1.1.4 -> 1.2.0).
     
    Incode likes this.
  38. kik1n01

    kik1n01

    Joined:
    Nov 30, 2019
    Posts:
    1
    I did the update, but on VS code shows a tons of warnings. But it works.
     
  39. v2-Ton-Studios

    v2-Ton-Studios

    Joined:
    Jul 18, 2012
    Posts:
    206
    I can confirm, again, that when using the LTS 2018 version of Unity VS Code debugging does not work :(.
     
  40. v2-Ton-Studios

    v2-Ton-Studios

    Joined:
    Jul 18, 2012
    Posts:
    206
    Just gave up on all this... wrestled with it for weeks... :mad: finally just installed VS Community 2019. Works great. Yea it's not as light and slick, but the debugging works reliably and lets face it, proper VS is a heck of an IDE.

    Click to resolve headaches: https://visualstudio.microsoft.com/vs/unity-tools/
     
  41. Incode

    Incode

    Joined:
    Apr 5, 2015
    Posts:
    62
    Hmm, my original post (downloading the .VSIX) should have fixed the issue, though I haven't tested in 2018 recently. I couldn't stand working on VS for more than a couple days :D
     
    v2-Ton-Studios likes this.
  42. v2-Ton-Studios

    v2-Ton-Studios

    Joined:
    Jul 18, 2012
    Posts:
    206
    Spent the day using it... I think you're half right... the window mgmt in Code is much nicer, but I now remember how much I actually hate its "smart" intellisense, its weird kinda hard to see hightlighting of intellisense results, and overall user model. Proper VS is just so much more consistent, it actually feels professional, robust, and fast :).

    Total aside: Makes me realise how clunky and fragile the Unity Editor is. Maybe 2019 is worlds better, but I doubt it... for me the dev team really does need to spend some time focused on bugs, perf and overall reliability.
     
    Last edited: May 2, 2020
    Quast likes this.
  43. MaximKondarev

    MaximKondarev

    Joined:
    Apr 3, 2020
    Posts:
    1
    So, it looks like there is no solution for this, right?!
    Tried everything in this thread and still intellisense does not "know" Unity classes... its absurd...
     
  44. v2-Ton-Studios

    v2-Ton-Studios

    Joined:
    Jul 18, 2012
    Posts:
    206
    It does indeed look like that for certain configs. For instance, I cannot get it working with 2018 Unity LTS build.

    It's frustrating. Unity is a tool I pay for. It's reasonable to expect a professional tool like Unity to support all official 3rd party tools. Especially one made by Microsoft. It's been several weeks and we've heard nothing from Unity on this.

    It's great what Incode and others have done to help, but it's not okay for Unity to offload their tooling support to the community.
     
  45. Peter5897

    Peter5897

    Joined:
    Jan 4, 2017
    Posts:
    20
    It depends on your situation, if you're on latest it should work fine.

    See:

     
  46. pitpit0

    pitpit0

    Joined:
    Mar 21, 2020
    Posts:
    1
    Intellisense wasn't working in any new project I create.
    Removing "Library" directory, snl and csproj files as suggested by @tcz8 makes it work again !

    Visual Studio Code: 1.44.2
    C# extension (in vsc) : 1.21.12
    Unity: 2019.3.12f1
    Visual Studio Code Editor (in Unity): 1.2.0
     
    Last edited: May 5, 2020
    Radivarig likes this.
  47. Organik05

    Organik05

    Joined:
    Feb 15, 2016
    Posts:
    3
    I bit the bullet and just installed Visual Studio Community, runs fine on my machine, but there is just something about code I prefer. Wish they would fix it and not leave it up to us to figure it out!
     
    v2-Ton-Studios likes this.
  48. jooleanlogic

    jooleanlogic

    Joined:
    Mar 1, 2018
    Posts:
    371
    I'll add my 2 cents having just installed on linux.
    Intellisense didn't work until I installed mono-devel, which I think is equivalent of adding the 4.7.1 framework assemblies for Windows which has been mentioned already.
    It now works with all latest versions below.

    2019.3.0f13
    VS Code Editor: 1.2
    VSCode: 1.45.1
    C# Extension: 1.21.18
     
    Philius342 likes this.
  49. Philius342

    Philius342

    Joined:
    Nov 30, 2019
    Posts:
    1
    Installing mono-devel fixed it for me. Thanks.
     
  50. dwroberts

    dwroberts

    Joined:
    Nov 22, 2019
    Posts:
    1
    After days of trying to install practically every version of dotnet anything, using an older extension worked (Win10x64). Thank you so much op, I want to cry for finally having this solved as I've been figuring it out for days.
    2019.4.0f1
    I don't have VS Code Editor?
    VS Code: 1.46
    C# Extension: 1.21.12
     
    Incode likes this.
unityunity