- Home /
About the Visual C# Express Editor limitation
The unity environment doesn't allow you to use Visual C# Express 2008 as the external editor, saying it can't be handled from outside. I was wondering if this is a legal/license limitation or a technical one.
If it is a technical limitation, I found this workaround by using DDE: 1) download ClassExec from http://fvue.nl/wiki/ClassExec 2) Create a batch file (I used runvc.bat) in the same directory where you opened ClassExec, and put in the following contents :
classexec %1 --class .cs
3) Associate the batch file as your external editor in unity. 4) If Visual C# Express is open in the background and has the sync'ed solution open, when you double click a script in the unity editor the selected file will open in the existing Visual C# window, allowing you to edit it with code completion and all the fun features.
I'm considering adding this workaround to the unity wiki, but don't want to do anything evil. Is this legal?
If anyone is still looking at this, there's now a Visual Studio Community Edition which means you can get all the Professional features for free, including full Unity integration.
Answer by Lucas Meijer 1 · Nov 26, 2009 at 01:40 PM
We use COM to control visual studio pro to open the correct file at the correct line. Microsoft disabled COM suport for visual studio express. I've tried several different ways to make it do what we want anyway, but in the end, I couldn't get any of these more hacky methods working reliably on different machines with different language settings etc.
Please note that you can still use Visual Studio Express just fine to open the generated .sln file, and edit with autocompletion etc.
You open to the correct line from within unity ? care to share your trick or script ?
I tried several things. $$anonymous$$ost stuff related to sending fake keyboard events in order to automate VisualStudioExpress. Check out something like AutoIt3. In the end it was just too damn hacky to be able to support.
Answer by duck · Nov 23, 2009 at 06:19 PM
Can't comment on the legality of it (IANAL) although my guess would be that it isn't illegal.
However you might want to consider this trick - rename your copy of Uniscite.exe to some other name to preserve it as a backup (eg, "UnisciteBackup.exe"). Then place your batch file in the same folder, with the original name of the Uniscite exe. Make sure 'uniscite' is selected as the default editor, and you'll find that Unity passes the line number along as a parameter too! (it doesn't seem to do this if you select a different external editor).
Now, I haven't used "ClassExec" before, but if it supports it some method of doing so, you can then incorporate the line number into your script so it jumps to the correct line :)
Hmm, interesting. The classexec method won't be able to do this because it just hooks on your windows settings and basically runs the program (and params etc) that are associated with the double clicking (or right clicking and selecting a certain action from the context menu) for a certain file type. It might be solvable by DDE launchers, although I haven't been able to get them to open the file in an existing instance of VCExpress, so I have up and took this method...
Still looking for some sort of authorization to share this, my guess is O$$anonymous$$ as well but prefer to be sure...
Answer by Ricardo · Nov 25, 2009 at 11:08 PM
I don't see why it'd be illegal, or even against either of the licenses. What that Unity error means is probably that they didn't program Unity to command Visual Studio to open and move to a line.
Answer by davebuchhofer · Dec 09, 2009 at 09:42 PM
As a slightly tangential addition to the OP's classexec workaround, you can also route which IDE is loaded by the .bat file with a small addition, for instance, i send the .js and .shader filetypes to the UnityDevelop, but you can just as easily have them open in UniSciTE.exe (in your programfiles\unity\editor\data\tools\uniscite dir.. )
set classExecPath="C:\classexec\classexec.exe" set UnityDevelopPath="C:\Program Files\UnityDevelop\Unitydevelop.exe" GOTO :%~x1
:.cs ECHO "CS PATH" %classExecPath% %1 --class .cs GOTO :endscript
:.js ECHO "JS PATH" %UnityDevelopPath% %1 GOTO :endscript
:.shader ECHO "SHADER PATH" %UnityDevelopPath% %1 GOTO :endscript
:endscript
Note that if you simply use 'start "" %1' then the file will open in whatever app you have associated with its file extension, which you can use to get the same effect.
Answer by Davaris · Mar 12, 2010 at 06:18 AM
I followed the classexec %1 --class .cs instructions from the original poster and all it does is open the cs files in WordPad. :(
Associate the .cs files to default to visual studio.. I had a problem with getting this to work at home on Vista, but it works fine here on XP64, and appears to work in my superficial testing of windows7