Well, that’s how it is right now. I’ve made some modifications though. First, if you are on a other platform than a Mac your c# file will be opened by the tool you’ve selected in your settings menu. Next I’ve integrated a little menu item where you can choose wether you like to use VSCode for c# files or not. This setting is user specific to every project member.
UPDATE 2: There are some additional changes… You can now open the whole project folder in VSCode within a simple menu item. In addition to that you can determine and send debugging information to VSCode.
If you are in play mode in unity simply hit “File → Set Debugging Port in VSCode”, switch back to VSCode and hit Play to debug!
Docs & Download here: GitHub - robin7331/UniVSCode: Opens C# files from Unity3D in VSCode
Is there a way to use unsafe code in VSCode? I’m building for iOS and some of the plugins I use require unsafe, but VSCode/OmniSharp doesn’t like it - it gives:
[ERROR:OmniSharp.MSBuild.MSBuildProjectSystem] Unsafe code requires the `unsafe' command line option to be specified
Which then means that the projects don’t load correctly and intellisense doesn’t work.
As far as I know, Unity also won’t let you use unsafe keyword unless you make some Mono modifications. Maybe try applying them also to Mono that OmniSharp uses?
@thoorne - thanks for the info - I haven’t been able to find anything recent on the Mono modifications. The only thing I found was from about 2010 but Unity has all changed since then.
Unity apparently allows it by using a gmsc.rsp or smcs.rsp file with the line -unsafe in it, and that allows it to work… it seems VSCode ignores this
After Updating to VSCode 0.7.0 I get an “Error: Failed to start OmniSharp” when loading my project. I will follow up if I find an answer.
Edit+Solution: I simply brew install mono and it worked again. I hadn’t installed mono separately before, and it seems that VSCode automatically picked up on the new version.
However all the autocomplete and suggestions are INSANELY slow now. I wouldn’t recommend updating. mono-sgen is constantly using 100% cpu and I have to wait for VSCode to come up with suggestions, first it’s basically telling me that every character I type is a syntax error for a minute.
I had everything working fine, now I can’t get any projects to open. Here is error I get, even when I create a new Unity project and attempt to open it with VSCode. Posted the same question on SO. Any help would be greatly appreciated…
[ERROR:OmniSharp.Startup] The project system ‘MSBuildProjectSystem’ threw an exception.
System.ArgumentException: Value does not fall within the expected range.
at Microsoft.CodeAnalysis.MSBuild.SectionBlock…ctor (System.String type, System.String parenthesizedName, System.String value, IEnumerable`1 keyValuePairs) [0x00000] in :0
You need to install the latest Mono (http://www.mono-project.com/download/). Microsoft updated OmniSharp to the latest version which requires a new Mono version. Alternatively, you can use homebrew to install Mono as mentioned by noio on his last comment =)
Note that at first I just downloaded the El Capitan version and installed that without removing the older mono versions. The installer set the Current symlink to point to the 4.2.0 version that was installed -but VS Code still showed the Omnisharp error. I had to remove the old versions of Mono before it used the 4.2 version.
Is there a VS Code setting where I can provide a path to the mono version that I want to use?
BTW: I also have the very high cpu usage issue when trying to do completion while typing code - the delay for completion is 5-10 seconds on my system.
Update: The delay has disappered on my system - now I have instant completion and mono-sgen rarely goes beyond 25% cpu usage.
I clicked the Flame icon in the bottom of VSCode and chose Change projects and opened the same project as before. Shortly after that completion was speedy again
I uninstalled the homebrew version of mono and got it from your link, @lprunk , the problems with slowness have gone away now.
~~ @frjtrifork I did not get the El Capitan version, and my CPU usage looks OK for now.~~
OOPS NOPE. Too soon. It’s still super slow. Like you said, code completion takes about 10 seconds. This is virtually unusable. Has anyone found a solution?
Still no luck with updated mono. Looks like there is some arg that OmniSharp doesn’t like in my .sln file, maybe a version number? Can anyone upload a .sln file that VSCode likes so i can compare?
I just installed the latest mono download from the link above 4.0.3, however when I run terminal mono --version it shows 4.0.2. Is that ok?
I posted the ‘workaround’ of change projects to make completion speedy again - but at that time I had not had VSCode running long enough apparently.
I have the same issue, completion is speedy immediately after doing the Change projects, but after a while it becomes slow again. Luckily doing the Change projects and selecting the same project again takes only a couple of seconds on my project so although it is annoying, I can live with that workaround for now.
I’ve been using omnisharp-atom for the last couple months and only heard about this editor recently. Is there anyone who has used both here and has a good sense of the pros/cons? Slowness is certainly an issue. But the most recent release of omniSharp-atom is actually pretty smooth on OSX. My first impression is that this would be the ideal editor for Unreal4 (MS Code )… I’ll have a peak on the boards over there to see what’s up…
Just grabbed the latest version last night and I have to say…it’s getting more promising for everyday One thing I’ve noticed when trying is the syntax highlighting…there is a lot of white… =O Is there a way to remedy this?
I assume that you’re using dotBunny’s VSCode script. That is an editor script so it should be in a subfolder named “Editor”. The “UnityEditor” namespace is not available in builds.
Thanks, I did manage to sort it out eventually. I noticed though that the latest update to VSCode seemed to break the integration somewhat? I couldn’t get any of the autocompletion stuff to work anymore. Not sure if that was just me though…
I’ve switched back to MonoDevelop for now. It’s just easier I think.