Setting up Visual Studio for Unity on Mac

This section covers issues specific to a setup where you have Unity running on a Mac and Visual Studio running under Windows in a VMWare Fusion or Parallels virtual machine.

For general information on working with Visual Studio and Unity, see: Setting up Visual Studio for Unity

Basic VMWare (or Parallels) and Visual Studio installation
Set up a VMWare Image with Windows XP and Visual Studio 2005 or 2008 (any edition from Express to Team System should do fine). You can probably also use Windows Vista or Windows 2003 Server. You can find the Express Edition for free at: www.microsoft.com/express/vcsharp/

This article assumes that you are already familiar with Visual Studio. If not, it's probably a good idea to do some Visual Studio tutorials first, before continuing (they should be available in the Visual Studio documentation).

I'm using VMWare, but others are using Parallels, so that should also work just fine.

Mapping the Unity Project to be Accessible from Windows
If you haven’t done so already, set up your Unity projects in a folder that is accessible to your Windows XP VMWare Installation. Personally, I’m using Documents/Games in my home-folder and have mapped my home-folder to drive I: on Windows XP via a network share. Under Games/projectname I have my projects. So I can access my Unity projects on Windows XP via I:/Documents/Games/projectname.

New approach
Assuming that you have a network drive mapped to your Applications folder (on the Mac) to drive letter F:, you can create to reference paths in the project properties:

F:\Unity\Unity.app\Contents\Frameworks\Managed\ -> this will give you UnityEditor.dll and UnityEngine.dll F:\Unity\Unity.app\Contents\Frameworks\Mono\lib\mono\unity\ -> this will give you the proper Mono-DLLs that Unity also uses (starting with Unity 3.0 ;-) )

Without those references, Unity won't find Boo.Lang, UnityEditor, UnityEngine and UnityScript (which are project references created by syncing the solution).

Old approach
Copy UnityEngine.dll and UnityEditor.dll to your Games-folder. To do that, open the console on Mac OS, and do something like (depending on your folder-structure):

cp /Applications/Unity/Unity.app/Contents/Frameworks/UnityEngine.dll /Users/ yourusername /Documents/Games/ cp /Applications/Unity/Unity.app/Contents/Frameworks/UnityEditor.dll /Users/ yourusername /Documents/Games/

(or, just locate Unity in your Applications folder, right-click: "show contents", then browse to Frameworks, and copy UnityEngine.dll and UnityEditor.dll wherever you like.)

NOTE: Synching the solution will remove the references to those DLLs. So after each sync, you'll have to re-add those DLLs. Obviously, this only is a problem on the Mac.

Documentation for UnityEngine.dll and UnityEditor.dll
Wanna have this?



Just drop [[Media:Visual_Studio_docs_2.5.zip|these two files]] in the same folder where you put the DLLs ([[Media:Visual_Studio_docs_2.1.zip|Unity 2.1 version]]).

Note: After Unity 2.6 and the built-in Visual Studio integration, you'll want to drop the files in your "Unity\Editor\Data\lib" folder. If you had an existing Visual Studio project, you will need to drop and re-add the UnityEditor.dll and UnityEngine.dll references (from the lib folder just listed) before the documentation will show up.

Note: In Unity 2.6, you need to make a copy of "UnityEngine.xml" and name it "UnityEngine-Debug.xml". Place in same folder.

You'll get inline documentation for all documented classes, methods and enumerations, both for UnityEngine and UnityEditor namespaces.

For some methods you'll even have parameter documentation. Basically, the newer the method, the more likely it is to have parameter docs... UT really is doing their homework so don't hesitate to nag them (by filing "documentation" bug reports) to keep improving the docs, they are a huge asset to the strength of Unity!

Creating a Local Project for Visual Studio
Create a project on your local  drive (to avoid security exceptions you may not wish to use a network drive).

In that project, create a folder  and put the   into that folder. Add this as a reference.

Right-click "References" in the project explorer, select "Add reference", "Browse", browse to where you put the DLLs, add them (you can select both at once). XML documentation will automatically follow. For later projects you can use the "Recent" tab instead.

Tips

 * Always leave the DLLs + XML docs in the same folder, this way when a new Unity release comes up, all you'll have to do is overwrite them and all your projects will stay up to date. If you don't want that, create a folder for each DLL version, or even create project-specific copies.
 * At this point, it might be a good idea to export your project to a template, so for later projects you can directly create a Unity project with everything referenced. I would post my own template but I doubt it would cross over to a different machine.

I’m using a Windows application so I could do basic debugging by creating some buttons to start actions (thanks to Lka for a tip how to do this, see: http://forum.unity3d.com/viewtopic.php?t=7062#50779 ).

Folder Setup in Unity Project
In your Unity project, create your own Asset folder if you don’t have it, yet (I’m using ). Under that folder create a folder specifically for your C#-Unity-Scripts (I call it Scripts). Add a C# script there in Unity.

In your VS.NET 2005 or 2008 project, add a folder. Select folder projectname and use Tools / Add Directory Content (this is what you downloaded and installed the plugin for in step 2).

Add-On for Convenient Adding of Unity Scripts Note
The section below is marked as obsolete claiming that the plugin is not needed because Unity now provides a mechanism for directly creating Visual Studio solutions from within Unity. However, this is only true of the Windows version. As these are instructions for making this work with the Mac version of Unity, that note is incorrect.

Also the latest version of Windows Studio may be higher than 9.0. In fact, as of this edit, it is 10.0.

This plug-in works as advertised with Visual Studio 2010 (with the appropriate edit to the .AddIn file)

Obsolete: Add-On for Convenient Adding of Unity Scripts
NOTE: As Unity now supports directly creating the solution from within Unity, this Add-On is obsolete.

Download and install this very practical addon

What you can use this for is conveniently add all scripts from a folder in one single "go".

Note: When you want to use this under Visual Studio 2008, you have to make sure that in your "My Documents" (or "Eigene Dateien") folder, in the "Visual Studio 2008" folder, there’s an "Addins" folder that contains the two files AddDirectoryContent.AddIn and AddDirectoryContent.dll. In AddDirectoryContent.AddIn, make sure that 8.0 is set to 9.0:

  Microsoft Visual Studio 9.0  […]

Thanks to benblo for this tip, see also: http://forum.unity3d.com/viewtopic.php?t=7062#50996

According to psynopticM, this may not work under Visual Studio 2008 Express: http://forum.unity3d.com/viewtopic.php?p=74325#74288

End of obsolete text.

'''Congratulations – now you can code C# for Unity in VS.NET 2005 / 2008. With Intellisense... and inline docs!'''