Best practices for working with Unity and Visual Studio

A developer creating a holographic application with Unity will need to switch between Unity and Visual Studio to build the application package that is deployed to HoloLens. By default two instances of Visual Studio are required (one to modify Unity scripts and one to deploy to the device and debug). The following procedure allows development using single Visual Studio instance, reduces the frequency of exporting Unity projects, and improves the debugging experience.

Improving iteration time

A common workflow problem when working with Unity and Visual Studio is having multiple windows of Visual Studio open and the need to constantly switch between Visual Studio and Unity to iterate.

Unity - for modifying the scene and exporting a Visual Studio solution

Visual Studio (1) - for modifying scripts

Visual Studio (2) - for building and deploying the Unity exported Visual Studio solution to the device

Luckily, there's a way to streamline to a single instance of Visual Studio and cut down on frequent exports from Unity.

When exporting your project from Unity, check the Unity C# Projects checkbox in the "File > Build Settings" menu. Now, the project you export from Unity includes all of your project's C# scripts and has several benefits:

Use the same instance of Visual Studio for writing scripts and building/deploying your project

Export from Unity only when the scene is changed in the Unity Editor; changing the contents of scripts can be done in Visual Studio without re-exporting.

With Unity C# Projects enabled, only one instance of each program need be opened:

Unity - for modifying the scene and exporting a Visual Studio solution

Visual Studio - for modifying scripts then building and deploying the Unity exported Visual Studio solution to the device

Visual Studio Tools for Unity

Use the Unity Project Explorer to find your script with the exact same hierarchy that Unity displays.

Get the Unity console directly inside Visual Studio.

Use wizards to quickly create or navigate to scripts.

Expose C# class variables for easy tuning

Make C# class variables public to expose them in the editor UI. This makes it possible to easily tweak variables while playing in-editor. This is especially useful for tuning interaction mechanic properties.

UWP Visual Studio solutions checked in to source control can get out-of-date after upgrading to a new Windows SDK or Unity engine. You can resolve this after the upgrade by building a new UWP solution from Unity, then merging any differences into the checked-in solution.