Search Unity

  1. Unity 2019.1 is now released.
    Dismiss Notice
  2. We've opened up a space to discuss, share feedback, and showcase everything related to the Unity Shader Graph! Come show us what you've made.
    Dismiss Notice

Can't get VSCode to work properly with Unity

Discussion in 'Linux Editor' started by Kurolox, Jun 28, 2018.

  1. Kurolox

    Kurolox

    Joined:
    Aug 13, 2015
    Posts:
    4
    I've been trying to get Intellisense to work, but I don't get any relevant autocompletion like other people I've seen here.

    I've followed the instructions on this post: https://forum.unity.com/threads/vscode-for-linux-not-opening-projects-correctly.527924/

    This is what I'm getting, compared to the screenshots in that thread. https://i.imgur.com/bDtoKzn.png

    Not sure what could be happening. The C# extension is installed, and mono too. I've followed the steps indicated here too: https://code.visualstudio.com/docs/other/unity but I can't get it to work properly.

    Here's how I have vscode set up from Unity: https://i.imgur.com/ROBbCEl.png

    I hope anyone here could have a lead regarding what I'm missing.
     
  2. Kurolox

    Kurolox

    Joined:
    Aug 13, 2015
    Posts:
    4
    I've found that the issue might be that Unity isn't generating .sln files, which VSCode seem to need in order for the imports to work. Any idea about why those files aren't being generated?
     
  3. DGLWilkins

    DGLWilkins

    Joined:
    Sep 25, 2012
    Posts:
    6
    Your dead on with the issue being Unity not creating the .sln files. I've been having the exact same issue as well since updating Unity.
     
    Last edited: Jun 30, 2018
  4. Kurolox

    Kurolox

    Joined:
    Aug 13, 2015
    Posts:
    4
    I've found a workaround to generate the .sln files.

    1. go to Edit -> Preferences, then select the External tools tab
    2. Ignore all advice given on other threads where you create an alias or a symbolic link to add custom arguments. Instead of that, in the External Script Editor field, select
      /usr/bin/code
    3. If you selected the correct executable, there shouldn't be any External Script Editor Args field.
    4. if you try to open any script from unity now, it will still won't work. Code files won't be generated, and only the script will be opened in code, instead of the folder. Don't worry.
    5. Go to Assets -> Open C# Project. Now code will open the project folder, the .stl files and other meaningful files will be generated (like the .vscode folder), and Intellisense will work properly.

    Let me know if it works for you too.
     
    unity_aTwq4Yux6lZwGw and NotSoAI like this.
  5. DevinDazzlr

    DevinDazzlr

    Joined:
    Dec 3, 2013
    Posts:
    2
    I think this is a bug with Unity 2018.2 (at least, that is when my troubles started) .. As you already pointed out, Unity no longer creates the .sln file. In my project, the .sln file is there but is no longer updated.

    At least for now, following your approach by going Assets -> Open C# Project works. Thank you :)
     
  6. unityoracle

    unityoracle

    Joined:
    Jul 3, 2018
    Posts:
    12
    This issue is that Unity Editor expects the file used to launch VSCode to have a specific name. It seems that unity will only trigger the .sln/.csproj generation routine if the filename matches a hard-coded value.

    Specifically, creating a symlink named "code" that opens VSCode fixed this issue for me. The normal binary was named "visual-studio-code", which Unity didn't recognize as VSCode.

    Unity devs may want to consider a more sophisticated method of determining whether the selected external editor is VSCode, VS, etc.
     
    Novack likes this.
  7. LitchiSzu

    LitchiSzu

    Joined:
    May 14, 2016
    Posts:
    17
  8. DGLWilkins

    DGLWilkins

    Joined:
    Sep 25, 2012
    Posts:
    6
    Didn't work for me maybe because I'm using Arch and getting VS code from the AUR and the executable is code-oss. In the end I fixed it by using the symbolic link method:

    sudo ln -s /usr/bin/code-oss /usr/bin/code


    Then followed your steps and got it working.
     
  9. marchinram

    marchinram

    Joined:
    Jan 28, 2014
    Posts:
    5
    Make sure project name doesnt have a space in it, messes with vs code
     
    The7thNoodle likes this.
  10. Justice0Juic3

    Justice0Juic3

    Joined:
    Apr 29, 2013
    Posts:
    175
    I don't have any External Script Editor field. Am I doing something wrong?
    I'm using 2018.3.0f2
     
  11. radixtrator

    radixtrator

    Joined:
    Jan 6, 2019
    Posts:
    1
    Look at the top of the menu items...
     
  12. SamFZGames

    SamFZGames

    Joined:
    Mar 2, 2014
    Posts:
    5
    M4RCIN and jacobgmartin like this.
  13. myroomtm

    myroomtm

    Joined:
    Nov 15, 2012
    Posts:
    7
    oh, thank you!! i love you
     
  14. uweenukr

    uweenukr

    Joined:
    Jan 17, 2011
    Posts:
    53
    This worked for me too. Ty Sam
     
  15. tmendez

    tmendez

    Joined:
    Oct 12, 2015
    Posts:
    25
    I just had to:
    Unity -> Preferences -> External Tools -> External Script Editor -> Browse -> Manually select VSCode

    I think the problem on my machine was two versions of VSCode fighting for Unity's love.