Search Unity

VS code - files not opened from Unity

Discussion in 'External Tools' started by Fr2, May 30, 2019.

  1. Fr2

    Fr2

    Joined:
    Jan 19, 2013
    Posts:
    22
    Unity version 2019.2.0b2
    VS Code version 1.34.0
    Using a mac 10.14

    When double clicking a .cs file in the Unity editor, VS launches and the .cs file opens. All good. However, if I try to open another .cs file from the Unity editor (same project), then the VS Code application is shown, but the file does not open. If I quit VS Code and try opening the file again from Unity, then the file opens OK.

    I've tried to resolve this by modifying the External Script Editor Args "$(ProjectPath)" -g "$(File)":$(Line):$(Column) in Unity, and also trying to edit the VSCodeScriptEditor's OpenOSX() function - neither have worked.
    I can open files from terminal using the command line arguments OK.

    Have verified that files open correctly using Unity 2018.3.8f1

    Driving me mad, any suggestions would be appreciated!
     
    Last edited: May 30, 2019
    Anthony0506, cplover, faust and 2 others like this.
  2. Forkeseal

    Forkeseal

    Joined:
    Feb 5, 2019
    Posts:
    4
    I have the same problem! It's driving me crazy. Any solution for this yet?
     
  3. Fr2

    Fr2

    Joined:
    Jan 19, 2013
    Posts:
    22
    Sorry no. I switched to Visual Studio as an interim measure, hoping a future update would fix the problem. I've had to park my unity project for a couple of months, so will revisit this problem soon. Really annoying!
     
  4. Paul_H23

    Paul_H23

    Joined:
    Jun 19, 2019
    Posts:
    14
    Same problem here, driving me nuts too, I hate Visual Studio Community, it feels so clunky compared to Code, any fix/workaround would be massively appreciated.
     
    mikapote likes this.
  5. Forkeseal

    Forkeseal

    Joined:
    Feb 5, 2019
    Posts:
    4
  6. Paul_H23

    Paul_H23

    Joined:
    Jun 19, 2019
    Posts:
    14
    That's what I originally followed, and it worked fine, right up until I updated to the latest 2019 version of Unity and then it all went pear shaped.
     
  7. Forkeseal

    Forkeseal

    Joined:
    Feb 5, 2019
    Posts:
    4
    After the update I had to remove the VSCode.cs file in Assets/Plugins/Editor and add it again. Worked fine after re-adding it.
     
    Paul_H23 likes this.
  8. Paul_H23

    Paul_H23

    Joined:
    Jun 19, 2019
    Posts:
    14
    Thanks, that seems to work for now. It's a shame that the native Unity support of VSCode doesn't work without needing a third party plugin, but I'll take anything right now.
     
  9. StarSmasher

    StarSmasher

    Joined:
    Aug 28, 2019
    Posts:
    2
    I'm experiencing the same problems as described above.
    I can confirm that Visual Studio Code works fine for me with Unity 2018.4.7f1
    And I can confirm that Visual Studio Code does not work for me with Unity 2019.2.4f1
     
  10. StarSmasher

    StarSmasher

    Joined:
    Aug 28, 2019
    Posts:
    2
    Also, it looks like "External Script Editor Args" in Edit -> Preferences -> External Tools seems to be new to Unity 2019. I don't see it in Unity 2018. Deleting the "External Script Editor Args" args at least allows VIsual Studio Code to open, but without the relevant file.
     
  11. Paul_H23

    Paul_H23

    Joined:
    Jun 19, 2019
    Posts:
    14
    Aaarrggghhhh I give up!!! Used VSCode for a while based on the advice above, then that became too slow to update when I make a change, compile times through the roof. So switched back to VS Community, now that doesn't work either. Is there any combination of Unity and IDE that actually works??!?!?!?!!?
     
  12. Anthony0506

    Anthony0506

    Joined:
    Oct 13, 2016
    Posts:
    61
    Is there a fix for this yet? this started happening to me this week.
     
  13. mattparkins

    mattparkins

    Joined:
    Apr 1, 2014
    Posts:
    30
    This is happening to me too on Mac. It's v frustrating!

    Update: For now I've gone back to Script Inspector 3 (which is very good also, and quick, but no debugging). Would love this one sorted.
     
    Last edited: Sep 12, 2019
    Anthony0506 likes this.
  14. jasonatkaruna

    jasonatkaruna

    Joined:
    Feb 26, 2019
    Posts:
    7
    Also unable to open VS Code. My problem extends to not just trying to open VS Code from the Unity Editor. I'm unable to open my project's folder from VS Code. Trying "Open with code" or selecting the folder from within vscode does nothing.


    EDIT:
    It looks like it works in a brand new project, so I'm not sure why my current project is preventing vscode from opening. Also, other text editors don't seem to be able to open.
     
    Last edited: Sep 13, 2019
  15. Fr2

    Fr2

    Joined:
    Jan 19, 2013
    Posts:
    22
    Just tried these instructions, and they do seem to work. Upgrading Unity to 2019.2.4f1 produced some script errors which broke the VSCode integration, but after fixing the errors and re-adding the VSCode.cs file it's working again.
     
  16. jasonatkaruna

    jasonatkaruna

    Joined:
    Feb 26, 2019
    Posts:
    7
    I'm convinced my particular issue is with a unity lock on my project going haywire, this could explain why I can't open the project folder in other editors.

    Does anyone have any debugging suggestions for fixing this particular issue? I've skimmed through vscode logs and Unity logs, and although I've probably missed something important, I didn't see any clues.
     
  17. Fr2

    Fr2

    Joined:
    Jan 19, 2013
    Posts:
    22
    That's a tough one. Assuming it's not related to source control locks or permissions, have you tried making a copy of your project, or creating a new project and copying your assets over?
     
    jasonatkaruna likes this.
  18. jasonatkaruna

    jasonatkaruna

    Joined:
    Feb 26, 2019
    Posts:
    7
    I've tried making a copy. I'll try to make a new project and copy the assets over.
     
  19. Owers

    Owers

    Joined:
    Jul 7, 2012
    Posts:
    36
    For what it's worth, my solution to this problem was to configure Windows to open .cs files in Visual Studio Code by default, and then change the 'External Script Editor' setting to 'Open by File Extension' in Unity preferences. Scripts will open from Unity using Visual Studio Code, but it won't open the C# project or use intellisense. To fix that, I then go to 'File > Open Folder...' in Visual Studio Code and open the Unity project folder. If Visual Studio Code is closed, then I have to repeat the process.

    It's a lousy solution, but it'll work for me until it gets officially resolved (hopefully).
     
  20. octav1an

    octav1an

    Joined:
    Jun 21, 2017
    Posts:
    1
    I have the same issue on Unity 2019.2.4. Most of the times VS Code won't open the cs files from Unity and does not even want to open Unity project when I go to File->Open Folder, nothing happens. However from time to time, if the planets are aligned, it seems to work correctly. That is frustrating. I have also tried VSCodium, at first it was fine, now it too doesn't work.
     
  21. Forkeseal

    Forkeseal

    Joined:
    Feb 5, 2019
    Posts:
    4
    I have just updated to Unity 2019.2.5f1 and VSCode now works perfectly!
     
  22. Amir-Ward

    Amir-Ward

    Joined:
    Jan 26, 2015
    Posts:
    30
    I'm on 2019.2.5f1 and it worked for a bit but now it won't even attempt to load VSCode at all.
     
  23. Muckel

    Muckel

    Joined:
    Mar 26, 2009
    Posts:
    435
    hello,
    well all your problems comes while you did not update the VSCode plugin in Packetmanager...
    Do it and no need for other stuff... the VSCode plugin is deprecated and not needed if you update via Packet manager.. best delete this old VSCode plugin from Editor folder... it works super without...

    looks like Unity is focussing more on Windows... hence the late fixes for iOS and Mac...
    i'm using UE4 on my Mac too... once i get my stuff working in UE i say goodby to Unity...
    i'm user from Version 1 where it was Mac only... i'm sooooo disappointed by Unity...
    they even don't do good beta testing anymore.... let the User do it its much cheaper ;-)
    look @ the last version of 2019.2 ... it's so buggy and output to Android & iOS too...
    since we don't get money for the time we spent searching bugs or discovering bug and take the time to document them... No Thank you nothing.... and maybe it get fixed mayyyyyyybeeee
    Unity had much better times as you see here in the forum....
    it's rare if you get a answer to your questions... no Unity peeps are here in the forum....
    if you have a problem... support doesn't exist... you can also not mail the problem...

    and than they ask our community what's up... why you don't submit games and apps for our campaigns ...
    loooool because UNITY3D doesn't care anymore what's up under the developer...
    Unity3d is now too big... they lost focus on quality and functionality ...
    they care now more for high end games that make 5% of the Unity user... only for marketing LOL
    they should better do there homework and focus what the mass needs ...
    a stable working editor on all platforms that are supported...!

    @ Unity3d
    Do your homework we pay you for this!!!
    and focus on quality not on features only 1-5% of the user want !!!

    M.