Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Visual Studio Code won't open through Unity Editor

Discussion in 'Editor & General Support' started by Solgryn, Oct 10, 2019.

  1. Solgryn

    Solgryn

    Joined:
    Jan 16, 2014
    Posts:
    8
    Hi,

    So randomly today visual studio code stopped working.

    • Whenever I try to open a script through the editor, nothing happens and visual studio code just hangs in the background processes doing nothing. No actual window will appear.
    • If I try to open file by extension (and not have the editor set to visual studio code), visual studio code actually opens but it's obviously not attached to unity so it's impossible to code in as it doesn't know the project and no auto completion. BUT It also makes this error in the console "Win32exception the system cannot find the file specified." so something is broken (but it opens it anyway, but wont attach to unity)

    I've tried reinstalling all of unity and unity hub, removing everything and installing it again. I've tried taking some of my backups and opening them, but it keeps happening.

    I recently updated to 2019.2.8, but it worked fine for 2 days prior and I didn't have this issue. It only started happening today. Other than not opening the code editor everything else works fine.

    Please help :( I can't work on the project at all cause of this bug.
     
    ph504 likes this.
  2. Domas_L

    Domas_L

    Unity Technologies

    Joined:
    Nov 27, 2018
    Posts:
    111
  3. Solgryn

    Solgryn

    Joined:
    Jan 16, 2014
    Posts:
    8
    Hello, I'm using Visual studio version 1.39.0. Are you sure u mean 1.1.10 ? or am i looking at the wrong version number.
    whenever i had the bug i tried updating it and it still didn't work.

    I reinstalled everything and everything is up to date.


    My problem isn't that scenes wont open in Unity. It's that trying to open scripts wont open visual studio. it says the file doesnt exist and i cant attach it to unity
     
  4. Domas_L

    Domas_L

    Unity Technologies

    Joined:
    Nov 27, 2018
    Posts:
    111
    I was talking about the Unity "Visual Studio Code Editor" package, which can be found in the Package Manager window. Also, make sure that you have selected "Visual Studio Code" as your external code editor.
    gPha3DnMNX.png external code editor preferences.png
     
  5. Shizola

    Shizola

    Joined:
    Jun 29, 2014
    Posts:
    446
    I've had so many problems with vscode I've given up and gone back to vs community.

    Just tried a new project with 2019.2.9 + package version 1.1.2, Assets > Open C# Project won't open or double clicking scripts. Other people have described it here: https://forum.unity.com/threads/vs-code-files-not-opened-from-unity.687100/
     
  6. Domas_L

    Domas_L

    Unity Technologies

    Joined:
    Nov 27, 2018
    Posts:
    111
    Thanks for clarifying! It seems that I've misunderstood the issue - this behavior is indeed an active issue which is not fixed yet, but it is currently being investigated. You can find more information and a workaround here: https://issuetracker.unity3d.com/is...external-script-editor-is-set-to-code-dot-exe
     
    Shizola likes this.
  7. konsic

    konsic

    Joined:
    Oct 19, 2015
    Posts:
    995
    Domas_L could you create automated process installing Visual Studio Code when installing Unity through Hub like Visual Studio Community?
     
  8. Domas_L

    Domas_L

    Unity Technologies

    Joined:
    Nov 27, 2018
    Posts:
    111
    Currently, we don't have this functionality, although you can choose not to install Visual Studio, and install another iDE of your choice later.
     
  9. TareqProjects

    TareqProjects

    Joined:
    Jun 27, 2016
    Posts:
    55
    Sorry for necroing this thread but I'm experiencing this exact issue. Using Unity version 2019.2.0f1 with VSCode package version 1.0.7. I was able to use Unity with said package until it stopped loading VS code when I tried to open a script. I've tried upgrading the package to version 1.1.2 and 1.1.3 but neither were able to resolve the issue. Has anyone managed to get VS code working from this problem?
     
    Last edited: Dec 9, 2019
  10. mrmelonmonkey

    mrmelonmonkey

    Joined:
    Sep 10, 2018
    Posts:
    2
    just pushing this as i am experiencing the exact same.
    thank you for looking into this again :)

    Edit: ok i solved it on my end by manually deleting all vs code extensions in User/.vscode/extensions and opening up a file with vsc i have in my unity project.
    vscode immediately recommended to install c# extension by microsoft wich i did. then i closed vs code and tried opening a script through the unity ditor and voila! it works again.
    make sure both programs, extensions and unity vscode package is up to date.
    hope this will help anyone experiencing the same issue!
    have a nice day!
     
    Last edited: Dec 29, 2019
  11. leegod

    leegod

    Joined:
    May 5, 2010
    Posts:
    2,345
    same here with visual studio community 2019
     
  12. KrlinM

    KrlinM

    Joined:
    Oct 23, 2013
    Posts:
    12
    I had same problem with Unity 2020.2.0b10, after doubleclick on script Visual Studio wont open.
    After hours of trying multiple things I deleted both "Visual Studio Code Editor" and "Visual Studio Editor" from "Window/Package Manager". It saved the issue. However I'm not sure if it was the right solution of the problem.
     
    Memnyatta and CleanGlassOFWater like this.
  13. Anraksha

    Anraksha

    Joined:
    Dec 9, 2016
    Posts:
    10
    You da real MVP
    that's been two day i'm on it
     
  14. Stridemann

    Stridemann

    Joined:
    Oct 12, 2013
    Posts:
    251
    If VS doesn't start or doesn't open the project after launch- try start unity from admin.
    (also, If breakpoints cannot be set- "Regenerate project files" button)

    One day I made compatibility for VS to always be launched from admin (some things doesn't work without admin) and forgot about that. Seems non-admin processes cannot launch the admin process.
     
  15. xXWarmachineRoXx

    xXWarmachineRoXx

    Joined:
    Sep 28, 2019
    Posts:
    3
    So you just have to do this :

    Install VSCode editor package from Unity->Pack->Manager->Packages: Unity Registry
     
  16. Siivul_DA_Goat69

    Siivul_DA_Goat69

    Joined:
    Oct 28, 2022
    Posts:
    1
    I have deleted and re-installed unity editor and Vstudio, like three times now. But all script lines associated with Unity wont be recognised by visual studios. Whats happening?
     
  17. vinvinn

    vinvinn

    Joined:
    Jan 7, 2015
    Posts:
    1
    I tried almost everything in this thread, I was able to open files in vs code but without intellsiense when both VS Editor and VS code editor unity packages were uninstalled.

    What fixed it with intellisense (ie what I wanted) is having the VScode package installed, and then in prefences>external tools, instead of selecting vscode from the list, I browsed for the executable.
     
  18. kryptin8

    kryptin8

    Joined:
    Apr 16, 2023
    Posts:
    1
    Similar issue to few of the above, but my script opens up in visual studio 2019 right now. The code i have in visual is just a simple edit name of game object. It even did the autocorrect parts. Once i save and go back to unity to press play, the game 'runs' but the name never changes. No errors on the visual side. any suggestions? I did the same process through Visual studio code and got the same results.
     
  19. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,963
    This may help you with intellisense and possibly other Visual Studio integration problems:

    Sometimes the fix is as simple as doing Assets -> Open C# Project from Unity. Other times it requires more.

    Other times it requires you also nuke the userprefs and .vsconfig and other crufty low-value high-hassle files that Visual Studio tends to slowly damage over time, then try the above trick.

    Barring all that, move on to other ideas:

    https://forum.unity.com/threads/intellisense-not-working-with-visual-studio-fix.836599/

    Also, try update the VSCode package inside of Unity: Window -> Package Manager -> Search for Visual Studio Code Editor -> Press the Update button

    Also, this: https://forum.unity.com/threads/no-suggestions-in-vscode.955197/#post-6227874
     
  20. ghaoyuxin

    ghaoyuxin

    Joined:
    Apr 22, 2017
    Posts:
    1
    hey all, I had a similar issue (different vs code and unity versions) but the cause of my issue is because I moved VS Code to a different folder after I set Unity External Tool selection as "visual studio code." So Unity remembered the old application file path, and the app no longer exist under the old file path. The fix is to just set the External Tool editor selection again. Hope this helps!

    The suggestion such as deleting "visual studio code" package worked for me as well, but I think that wasn't the root of the issue and I'd prefer to have the packages.