Search Unity

Unity doesn't find VS Code

Discussion in 'Linux' started by MadWatch, May 12, 2020.

  1. MadWatch

    MadWatch

    Joined:
    May 26, 2016
    Posts:
    112
    Hello Everyone

    While trying to get VS Code to work on Ubuntu 20.04 I stumbled across a problem that looks very much like a bug in Unity.

    When I open the Assets menu and do "Open C# Project", Unity says that VS Code is not installed and ask if I want to install it. If I click Yes then is opens Ubuntu Software and offers to install the Flatpack version of VS Code.

    If VS Code has been installed with the official Deb from Microsoft, or with the Snap package from Ubuntu, Unity doesn't detect it. Whenever I do "Open C# Project" it will insist that VS Code is not installed, even though it is.

    If I install VS Code with Flatpack then Unity detects it and launch it. However I didn't manage to get Omnisharp working with the Flatpack version of VS Code. It works fine with the Deb or the Snap but not with the Flatpack. I thought it might be a sandboxing issue and tried tweaking the permissions but I couldn't get it to work.

    So, why doesn't Unity detect the Deb or Snap install of VS Code? What exactly is Unity looking for when it checks if VS Code is installed?

    This is a problem because using "Open C# Project" is the only way I know to make Unity generate the SLN, and without SLN there is no IntelliSens working. Is there another way to force Unity to generate the SNL?

    The only workaround I found so far is to install Rider and configure Unity to use it instead of VS Code. Then, when I do "Open C# Project", Unity will generate the SLN and launch Rider. I can then quit Rider and open the SLN with VS Code. That suck though. I wish I could find a better way to handle this.

    Should I report a bug?

    Best Regards.
     
  2. NiirB

    NiirB

    Joined:
    Jun 21, 2019
    Posts:
    13
    Hey,

    I use elementary and had to to go external tool preferences and manually locate the VS code executable to have unity realise that I have it. Try doing that and see if it fixes the issue.
     
  3. Adrien-Gannerie

    Adrien-Gannerie

    Joined:
    Feb 18, 2015
    Posts:
    12
    Hi guys, someone found a solution for that issue with Unity and VSCode ? Best regard.
     
  4. MadWatch

    MadWatch

    Joined:
    May 26, 2016
    Posts:
    112
    That problem has been fixed for me with newer versions of Unity. But that was a while ago. I'm not using the newest versions of Unity now and I stopped using VS Code anyway so I don't know what's the status right now.

    Some things I learned:
    • Install Unity with the official appimage for UnityHub, not with the non official Flatpak that's on Flathub (or any other non official package).
    • Install VS Code with Snap, not Flatpak. Unity doesn't detect applications installed with Flatpak (maybe that's been fixed on newer versions, I didn't try).
    • You need the Visual Studio Code Editor package installed within Unity. Go to Window -> Package Manager and make sure it's there.
    • Got to Edit -> Preferences -> External Tools and in the External Script Editor menu you should see Code. That's what you should choose.
    • Go to Assets and choose Open C# Project. That should open VS Code load your project's solution. From there on VS Code will remember it and you can just launch it manually whenever you need.
    • Remember that VS Code sucks. I had plenty of breakage while I was using it. I had updates of VS Code making it non detectable by Unity, or making Intellisense stop working. I often had to downgrade VS Code, or the OmniSharp plugin, or the Unity Visual Studio Code Editor package in order to get things working again. That's why I stopped using it. I'm not up to date on the current situation. If you can't make it work, that might be because it just doesn't work.
     
  5. Adrien-Gannerie

    Adrien-Gannerie

    Joined:
    Feb 18, 2015
    Posts:
    12
    Thanks for your help, which IDE do u use now on linux with unity ?
     
  6. MadWatch

    MadWatch

    Joined:
    May 26, 2016
    Posts:
    112
    I'm using Rider. It's not free and it's not perfect but at least it works and it has some cool features.

    I couldn't find anything better. VS Code works but only when it wants to. And I never managed to get IntelliSense to work on Atom or Sublime Text. Maybe there are other alternatives I'm not aware of.
     
    Balthamet likes this.
  7. hecker_de

    hecker_de

    Joined:
    Mar 28, 2021
    Posts:
    19
    Omnisharp ist quite a diva, indeed. It took me some effort to get it working initially, and it totally refused to work in VS-Codium (which suppsedly should be the same code). Then there's an update for the dotnet package set (from 5.0.4 to 5.0.5). Installed it - Omnisharp breaks again. Eventually I resorted into downgrading dotnet back to the previous version and purged/reinstalled VS-Code. Start a new Unity project, Omnisharp fails again, at first. Eventually got it going for the new project as well...
    There's an update pending for VS-Code (1.55.0 to 1.55.1), but I don't dare install it, either.

    I set all related packages (dotnet and code) on hold ("apt-mark hold <packagename>") to exempt them from updating.
     
  8. hecker_de

    hecker_de

    Joined:
    Mar 28, 2021
    Posts:
    19
    I added the repository from mono-project.com to my apt sources and upgraded to the current Mono 6.12-xamarin. This seems to have fixed the issues with Omnisharp, at least for now...
    VS-Code and dotnet packages are updated now as well...
     
  9. unity_0405F7B26AD0C1BB04E9

    unity_0405F7B26AD0C1BB04E9

    Joined:
    Apr 26, 2021
    Posts:
    1
    I highly recommend using this IDE - Consulo