Unity 4 won't work with Visual Studio 2010

I had Visual Studio working with Unity 3, but after I updated to Unity 4, Visual Studio will not open up when I click errors in the consoles or on scripts in the project panel.

Everything I find on setting up Visual Studio is Unity 3 related, and doesn’t seem to be working for me. The pop up always says “opening Visual studio, this may take a few minutes” but then ALWAYS opens up monodevelop. There’s even a solution file in my project folder that works if I open it up, and I can edit the scripts and compile them from Visual Studio, but clicking on debugging lines in the console will just open up Monodevelop.

Any idea why?

Bumping because I REALLY want to be able to use VS again…

I suggest you to use monodevelop .because vs2010 cannot use breakpoint in debug mode . i was a m$ C# developer for 3 years , but now had to adapt monodevelop.

Hi,

Did you check:

Edit >> Preferences >> Eternal Tools >> External Script Editor?

Where do you have Visual Studio installed?

I have the same problem, and it seems that Unity 4 can’t find the Visual Studio 2010 where it’s actually located. Unity 3 works just fine.

Using ProcMon ( http://technet.microsoft.com/en-us/sysinternals/bb896645.aspx ) I was able to pinpoint that the Unity.exe indeed does read the registry (HKLM\SOFTWARE\Wow6432Node\Microsoft\VisualStudio) but it doesn’t read the InstallDir path that would contain the install directory! On my machine, the VS2010 is installed on e-drive (E:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE)

Right after that Unity tries to find E:\Program Files (x86)\Microsoft Visual Studio 10.0\IDE\devenv.exe, but it’s not found, as the place for the devenv.exe in VS2010 install is Common7\IDE

Later on in the ProcMon log Unity.exe tries to find file C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\Devenv.exe which obviously doesn’t exist as I have it installed on the E drive.

Thus, I see no visual studio 2010 in the dropdown menu for external tools.

HOWEVER there’s a fix!

This only works if your problem is that Visual Studio is installed outside the default location (c:\program files (x86)\ etc).

Install a program called Link Shell Extension (http://schinagl.priv.at/nt/hardlinkshellext/hardlinkshellext.html

The right-click and drag the visual studio 10.0 folder from your alternative install location (e:\program files (x86)) to the default install location (c:\program files (x86)) and choose “drop here…” → “junction”. This will create a NTFS junction point on your c drive which will direct all access to that particular directory to e drive (or any other place you had your VS2010 installed on).

Start Unity and voila! you should see Visual Studio 2010 in the list of external editors.

Note that this same trick works for the external merge tools as well such as Perforce P4 merge.

It’s really a sloppy programming from Unity has these paths hardcoded into the executable instead of just reading the install location in the registry.

@ snlehton

My VS is installed in the default directory. In fact, visual studio is in the list of external editors. It even says it’s trying to open it up when I open a script through unity, or double click a compiler error in the console. However, unity ends up opening Monodevelop instead of Visual Studio. Even if I have Visual Studio already open, it doesn’t open the file up in that visual studio instance.

In Unity 3 it worked absolutely fine as long as VS was already running before Unity opened up. However, in Unity 4 everything LOOKS set up correctly, but it always ends up opening Monodevelop instead.

@ Mike Bastien
Yes, it is set to Visual Studio 10 there.

@ tao.tao
I would love to just use monodevelop, however there are bugs after bugs after bugs with using it on my machine in Windows 7. For example, right now Monodevelop will not highlight 99% of syntax errors such as wrong variable or functions names. This is absurd, as it is the basics of a modern IDE. I also jsut recently found out how to fix the issue with the invisible underscore if it is the first character in a row (I had to switch to the Visual Studio theme). Apparently no one else had this underscore issue since I couldn’t find an answer anywhere and I had to fudge around with stuff myself and fix it on accident.

In the past I also had constant crashes in Monodevelop when I tried to refactor the name of a variable that spanned several scripts. My new code base is not large enough to test if that is still the case.

Also, in Unity 3, when I would double click anything in the console, it would bring up my IDE. However in Unity 4, even when using Monodevelop it will not automatically pop up my IDE. It will highlight the line for me, but I have to bring up the IDE manually from the taskbar.

At the moment, if I can get correct syntax error highlighting back in Monodevelop, I’d be fine with using it. Any idea how to fix it?

Running Unity as Administrator will fix this.

I had the exact same problem. Worked on 3.x, failed on 4.x, opening in MD.

Right click Unity on Win7 taskbar > properties > Advanced > check Run as Administrator checkbox. When you click to start Unity, you will have to confirm via UAC that you are an admin (unless you turned this off, but you shouldn’t).

It’s worth noting that there is no reason you can’t still use Visual Studio because of this. Just open the generated .sln file in VS separately, as in open VS, open solution, pick YourProject-csharp.sln, and you’re good to go. Using just this method, you can’t double-click scripts in Unity to get them open in VS (it will open Monodevelop or whatever other external program you set), or double-click error lines in the console, but that’s not much more than a small inconvenience.

Thanks, this totally worked for me.