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. Dismiss Notice

VS code - files not opened from Unity

Discussion in 'Code Editors & IDEs' started by Fr2, May 30, 2019.

  1. Lightning_A

    Lightning_A

    Joined:
    Nov 30, 2018
    Posts:
    7
    ...
    I had this problem for one of my projects on Windows 10. I tried restarting my computer and it didn't work. Then I restarted and installed a quick update for my computer and it's working now. Weird.
     
  2. xsyww

    xsyww

    Joined:
    Dec 14, 2016
    Posts:
    1
    My solution to this problem is below and my environment is: win10 + u3d 2019.2.12f1.
    1. open your unity editor and double click on one .cs file ( and of cource, vsCode didn't start and show code),
    2. open your Windows TaskManager and force kill all Visual Studio Code processes, maybe some warning messages would appear and ignore it.Make sure all vscode process was killed.
    3. try double click .cs file in unity editor, and it works in my pc.

    I don't need repeat these operation, restart unity editor is still no problem with vsCode.
     
  3. BeginnerPolymath

    BeginnerPolymath

    Joined:
    Jul 31, 2015
    Posts:
    38
    If you try open .cs file but he didnt open, you can try open VSCode and click any Recent project, maybe is help you upload_2019-11-28_23-22-2.png
     

    Attached Files:

  4. Inc4nuS

    Inc4nuS

    Joined:
    Apr 13, 2016
    Posts:
    5
    I've installed the plugin and didn't work. So what I did was see the Processes from windows and to my surprise, there were a few of Visual Studio Code. Finished them all, closed unity and voilá. It worked.
     
  5. frixou89

    frixou89

    Joined:
    Oct 28, 2019
    Posts:
    1
    This worked for me right away after I tried everything else
     
  6. Brilath

    Brilath

    Joined:
    Jan 5, 2018
    Posts:
    1
    So my VS code was working until I started my new project and I believe it is due to me having spaces in my directory path. Hope this simple fix works for you all.

    Unity Version: 2019.2.11f1

    G:\UnityFun\Classic Clashing (Didn't work)
    G:\UnityFun\Classic-Clashing (Worked)
     
  7. RChrispy

    RChrispy

    Joined:
    Dec 18, 2013
    Posts:
    71
    I do not use any plugin.

    As I saw that several people have this proplem I wanted to share a simple solution that worked for me.



    Just paste this into your External Script Editor Args after choosing Visual Studio Code:
    Code (JavaScript):
    1. . -n -g $(File):$(Line)
    For people who want to know what this actually does:

    . - takes the current directory as unity uses the project folder to open its internal cmd(or powershell I am not sure) it will point to your project folder perfect
    -n - will always create a new window normally but this will not happen if it is a folder! by default vscode uses -r but it has a problem with unitys terminal session so the -n fixes this issue :)
    -g - is a goto to open a file at specific line if line is not provided it will just open at start of file.

    Sidenote:
    Seems I only face this problem on mz windows10 machine it works fine on my mac without changing the parameters.
     
  8. RChrispy

    RChrispy

    Joined:
    Dec 18, 2013
    Posts:
    71
    ps: just saw you can also use:
    Code (JavaScript):
    1. "$(ProjectPath)" -g "$(File)":$(Line):$(Column)
     
    Personuo likes this.
  9. Personuo

    Personuo

    Joined:
    Mar 19, 2014
    Posts:
    122
    “ $(ProjectPath)” -g“ $(File)”:$(Line):$(Column)
    Ťhis is useful to me
     
    RChrispy likes this.
  10. gowthamact2022

    gowthamact2022

    Joined:
    Jun 22, 2021
    Posts:
    10
    Just uninstalled and reinstalled VS code ... it worked for me
     
  11. hippogames

    hippogames

    Joined:
    Feb 5, 2015
    Posts:
    228
    Removing the "Visual Studio Code Editor" package also helped me. Now Unity opens VS when I click .cs files.
     
  12. IFCreative

    IFCreative

    Joined:
    Sep 21, 2020
    Posts:
    6
    So what I did to fix this is I directly dragged the assets folder into vscode and then accessed my scripts from there
     
  13. CATMASTER5555

    CATMASTER5555

    Joined:
    Nov 27, 2021
    Posts:
    2
    When I try to open the code, it doesnt give code. Instead, it just shows a picture of a paper. How can I get to the code?
     
  14. IFCreative

    IFCreative

    Joined:
    Sep 21, 2020
    Posts:
    6
    does the file have .cs after it? and are you opening that script