How to use Visual Studio Code as Unity3d script editor

vscode_256x256

Visual Studio Code has landed – a new code editor in the Visual Studio family that runs on both Windows, OSX and Linux.

My first thought when I saw Scott Hanselman show it on the BUILD 2015 keynote were how and if I could use this as the script editor for Unity3d C# scripts. MonoDev is just not my favorite editor.

The good news is that it is possible and simple!

On Windows

  1. Install Visual Studio Code :)
  2. Open Unity3d.
  3. Edit->Preferences->External Tools.
  4. In External Script Editor select Browse. Browse to C:\Users\USERNAME\AppData\Local\Code and select update.exe.
  5. In External Script Editor Args put in: –processStart Code.exe
  6. Close the window and you are set to go.

On OSX

  1. Install Visual Studio Code :)
  2. Unity->Preferences->External Tools
  3. In External Script Editor select Browse. Browse to and select Applications->Visual Studio Code.app.
  4. Close the window and you are set to go.

Applies to both Windows and OSX

The first time you double click on a C# script inside Unity3d, Visual Studio Code will not recognize the solution (.sln) file. Find the little “flame” in the bottom of Visual Studio Code, click it and select the .sln file for your project.

VisualStudioCodeProjectSelector

 

Actually this little “flame” is the real fixer for some Unity3d related problems, as with this solution VSCode will just open when ever you double click a C# script. So if you switch between more Unity3d projects, it’s not that ideal, as you need to go to File->Open Folder and select the folder with the .sln file in. Then you can select that .sln using this “flame” icon and you have IntelliSense and can start coding.

After you have done this, you have IntelliSense etc.

VSCodeIntellisenseUnity3d

I currently have not figured out the args that tells Visual Studio Code which file it should open. I know we in the Unity3d External Script Editor Args and put in “$(File)” with the file we double clicked. So it is just a matter of time before I figure out what the command in Visual Studio Code is. I have tried various combinations of –file, without any luck. If you know, let me know and I will this post.

Luckily, Visual Studio Code can do some awesome tricks, so you just hit CTRL+T (Windows) / CMD + T (OSX) and start to type the name of the script you would like to edit. Also remember to read about all the other features VSCode comes with.

Azure Website – The page cannot be displayed because an internal server error has occurred

Tonight I had some problems with an old .NET 2.0 site that I wanted to move from my old host to Azure Website. I did not want to change anything on the site, I just wanted it to run on Azure.

So I created a Azure Website for it and uploaded all the files via FTP – no problems of cause. I then hit the site and got some pretty useless windows errors:

“The page cannot be displayed because an internal server error has occurred.”

As a .NET developer I of cause tried to set CustomErrors=”Off” in Web.config, as the first thing, but that did not change anything.

I googled it with Bing (Scott Hanselman joke), and found that I was not the only one who found this error message useless, so I found a solution.

I enabled diagnostics in Azure Portal on the Website under the Configuration tab, scroll to the bottom. And set both application and site diagnostics on and to Verbose, see screen below.
It is important to turn on the Detailed Errors Messages.

Screen Shot 2014-12-28 at 23.33.20

 

After enabling some diagnostics, save and restart the website, just to be sure.

I then hit the website sometimes and went into the SCM for the site.

https://YOURSITENAME.scm.azurewebsites.net/

I do not think there is a link to this inside the Azure Portal currently (december 2014), so you just browse to your site and put in this little .scm.

In here you can do a lot of things, but what you want to do here is: Tools -> Diagnostics Dump.

This will give you a .zip file. Browse to LogFiles->DetailedErrors and here you should see some error pages.

I looked into some of these and could see the same error on all of them. Basically it said:

“An ASP.NET setting has been detected that does not apply in Integrated managed pipeline mode.”

In my case, I did not want to change anything on the actually site, I just needed it to run. So I went into the Configuration tab and changed from Integrated Mode to Classic – Bum! – site was running on Azure!

Hope this helps somebody out there.

With Mercurial/Git – contributing is SO easy

In relation to my post some days ago about social coding and DVCS, I had a great sample the other day why this is so great.

I recently upgraded my blog to the latest version of BlogEngine.net, which wasn’t easy. I guess most of my problems were because I went from version 1.5 to 2.5 or something, which is a pretty big jump.

Nevertheless, I had a lot of problems to just make a clean installation of BlogEngine.net work on my host. My blog runs on Shared-hosting, which gives some wierd problems from time to time.

I managed to google my way to resolving all the errors I ran into – that’s great!

Continue reading “With Mercurial/Git – contributing is SO easy”