Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

VS code: can I open a file without exiting current workspace

Discussion in 'Code Editors & IDEs' started by bitinn, May 15, 2018.

  1. bitinn

    bitinn

    Joined:
    Aug 20, 2016
    Posts:
    961
    With Unity integration enabled, it seems I am not able to open a file without VS code existing current custom workspace (which usually include multiple root folders).

    I can understand why Unity ask VS Code to switch workspace, but it's not what I want. Is there a workaround for this?
     
  2. JeremyBois

    JeremyBois

    Joined:
    Oct 25, 2017
    Posts:
    1
    It’s possible using custom command arguments.

    Go to Preferences then External Tools and change the field External script editor args to -g "$(File):$(Line)".

    When Visual studio code is selected, this field is hidden. As a workaround you can create a vscode.bat (Windows) that launch your visual studio code executable (more at https://stackoverflow.com/questions...ltiple-workspaces-when-using-vscode-as-editor).

    If like me you don’t want to see a command terminal launch in the background each time you open a script, you can create an executable version of your batch file with Slimm Bat to Exe (https://download.cnet.com/Slimm-Bat-to-Exe/3000-2216_4-75834541.html?part=dl-&subj=dl&tag=button)

    Attached a zip with the vscode.bat pointing to my vscode path and the resulting executable with a tiny icon.
    Of course if your installation directory is different you should change it in the batch file and then recreate the executable.

    I hope that helps,
     

    Attached Files:

    AtitudeGames likes this.
  3. AtitudeGames

    AtitudeGames

    Joined:
    Dec 23, 2018
    Posts:
    3

    Thanks,
    helped me!
    But i edited the script editor args to: -g $(ProjectPath) "$(File):$(Line)" this way the vs code open with project open. obs: for some reason i had change my target framework from 4.7.1 to 4.6.1
     
    Last edited: Jan 15, 2019