When you’re creating a mixed reality application with Unity, you need to switch between Unity and Visual Studio to build and deploy the app package to HoloLens or an immersive headset. By default, two instances of Visual Studio are required - one instance to modify Unity scripts and another to deploy to the device and debug. The following instructions let you develop using a single Visual Studio instance, reducing the frequency of exporting Unity projects and improves the debugging experience.
Support for .NET scripting back-end in Unity was deprecated in Unity 2018 and removed as of Unity 2019+, so we recommend you switch to IL2CPP. However, you may experience longer build times from Unity to Visual Studio. To improve for faster iteration, set up your environment for best compilation results:
1) Use incremental building by building your project to the same directory every time, reusing the pre-built files there 2) Disable anti-malware software scans for your project & build folders
Review Optimizing Build Times for IL2CPP for more info. Also, review Debugging on IL2CPP Scripting Back-end.
Consider installing the UnityScriptAnalyzer Visual Studio extension. This tool analyzes your Unity C# scripts for code that can be written in a more optimized manner.
Download Visual Studio Tools for Unity
Benefits of Visual Studio Tools for Unity
There are two ways to expose class variables. The recommended way is to add the [SerializeField] attribute to your private variables. Serialized fields can be accessed from the editor but not programmatically exposed. The other option is to make C# class variables public to expose them in the editor UI.
Both approaches make it possible to easily tweak variables while playing in-editor, which 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 out-of-date solutions after by building a new UWP solution from Unity and merging differences into the checked-in solution.
Storing assets in text format makes it easier to review content change diffs in Visual Studio. You can store assets in text format by selecting Edit > Project Settings > Editor and change Asset Serialization mode to Force Text. However, merging text asset file changes is error-prone and not recommended, so consider enabling exclusive binary checkouts in your source control.