How To Use Visual Studio For Mac

-->

The DVD may show up on the Mac desktop. If it does, drag it to the Trash to eject the DVD. Install Visual Studio. Put in the Visual Studio Disk; While Windows is not running, Click Storage, the CD/DVD Icon, and set the CD/DVD Device to Host Drive. Start Windows again. The Visual Studio DVD should show up in Windows.

In this section, you'll learn how to use Visual Studio for Mac Tools for Unity's integration and productivity features, and how to use the Visual Studio for Mac debugger for Unity development.

Opening Unity scripts in Visual Studio for Mac

Once Visual Studio for Mac is set as the external script editor for Unity, opening any script from the Unity editor will automatically launch or switch to Visual Studio for Mac, with the chosen script open.

Alternatively, Visual Studio for Mac can be opened with no script open in the source editor by selecting Open C# Project from the Assets menu in Unity.

Unity documentation access

Visual Studio for Mac Tools for Unity includes a shortcut for accessing the Unity API documentation. To access Unity API documentation from Visual Studio for Mac, place the cursor over the Unity API you want to learn about and press ⌘ command + ‘.

IntelliSense for Unity messages

The Unity engine broadcasts messages to MonoBehaviour scripts, allowing developers to write code that reacts to messages such as OnMouseDown, OnTriggerEnter, etc. Because these are not virtual methods in the base MonoBehaviour class, some IDEs such as MonoDevelop lack code completion functionality for Unity messages.

However, Visual Studio for Mac Tools for Unity extends its IntelliSense functionality to Unity messages. This makes it easy to implement Unity messages in MonoBehaviour scripts, and assists with learning the Unity API. To use IntelliSense for Unity messages:

  1. Place the cursor on a new line inside the body of a class that derives from MonoBehaviour.

  2. Begin typing the name of a Unity message, such as OnTriggerEnter.

  3. Once the letters 'ont' have been typed, a list of IntelliSense suggestions appears.

  4. The selection on the list can be changed in three ways:

    • With the Up and Down arrow keys.

    • By clicking with the mouse on the desired item.

    • By continuing to type the name of the desired item.

  5. IntelliSense can insert the selected Unity message, including any necessary parameters:

    • By pressing Tab.

    • By pressing Return.

    • By double-clicking the selected item.

Adding new Unity files and folders

While you can always add new files to a Unity project in the Unity editor, Visual Studio for Mac allows for easily creating new Unity scripts, shaders, structs, enums, and folders from within Visual Studio.

Add a new C# MonoBehaviour script

To add a new C# MonoBehaviour script, right-click on the Assets folder or one of its subdirectories in the Solution pad and select Add > New MonoBehaviour.

Add a new Unity shader

To add a new Unity shader, right-click on the Assets folder or a subdirectory in the Solution pad and select Add > New Shader.

Add a new folder

To add a new folder, right-click on the Assets folder or a subdirectory in the Solution pad and select Add > New Folder.

These additions are reflected in the Project window of the Unity editor.

To rename a file or folder

right-click on the item to rename in the Solution pad and select Rename....

Note

If you have a new Unity project with no scripts and the Assets folder does not show up in the Solution pad in Visual Studio for Mac, add an initial C# script from within the Unity editor.

Unity debugging

Unity projects can be debugged with Visual Studio for Mac.

Start debugging

Microsoft Visual Studio For Mac

To start debugging:

  1. Connect Visual Studio to Unity by clicking the Play button, or type Command + Return, or F5.

  2. Switch to Unity and click the Play button to run the game in the editor.

  3. When the game is running in the Unity editor while connected to Visual Studio, any breakpoints encountered will pause execution of the game and bring up the line of code where the game hit the breakpoint in Visual Studio for Mac.

Start Debugging in a Single Step

Starting debugging and playing the Unity editor can be completed in a single step directly from Visual Studio for Mac by choosing the Attach to Unity and Play configuration.

Stop debugging

How To Use Visual Studio Community

To stop debugging:

  1. Click the Stop button in Visual Studio for Mac, or press Shift + Command + Return.

Note

If you started debugging using the Attach to Unity and Play configuration, the Stop button will also stop the Unity.

To learn more about debugging in Visual Studio for Mac, see Using the debugger.

How To Use Visual Studio Code For Mac

How To Use Visual Studio For Mac

Visual Studio for Mac was released just under two months ago at Build 2017, and already we’ve seen tremendous growth in .NET developers working on the Mac. Visual Studio for Mac enables you to build native apps for macOS, native mobile apps for iOS, tvOS, watchOS, and Android, using Xamarin and Xamarin.Forms; and web sites and services using ASP.NET Core. You can also use Unity to build cross-platform 3D games.

To help new Visual Studio for Mac developers get started, we’ve created some hands-on labs to walk through some of its exciting new features. The first two labs are available today, for Unity game development and connecting to Internet of Things (IoT) devices, and we’re planning to release 4 more in the coming weeks.

Lab 1: Building Games with Unity in Visual Studio for Mac

How To Use Visual Studio For Mac

The first hands-on lab demonstrates how to build and debug Unity game projects. It guides you through 4 tasks:

  1. Setting up a basic Unity project
  2. Working with a 3D game scene
  3. Debugging the game script
  4. Exploring additional features that support game development.

Follow these instructions to download and install Unity, then use it with Visual Studio for Mac to script and debug a 3D game scene.

Lab 2: Targeting IoT Devices in Visual Studio for Mac

Our second lab shows you how to create apps that run on an IoT device – such as the popular Raspberry Pi – from Visual Studio for Mac. It guides you through 3 tasks:

  1. Setting up your Raspberry Pi
  2. Creating the IoT project
  3. Extending your IoT app with Xamarin components to add additional features.

This functionality is currently in preview, but we’ll make sure to update the lab if any changes will be necessary when we ship it in a stable release.

How To Use Visual Studio For Mac

Follow these instructions to write your first IoT code, then visit our IoT samples for more ideas.

Get Started

How To Use Visual Studio For Mac

Download Visual Studio for Mac today, and visit our labs repo on GitHub to give game development a try or connect to an IoT device. With the Community Edition it is easy and free to get started. Keep an eye on this blog for more labs that demonstrate all the other great features of Visual Studio for Mac.

Visual Studio For Mac Os

Craig Dunn, Principal Program Manager
@conceptdevCraig works on the Mobile Developer Tools documentation team, where he enjoys writing cross-platform code for iOS, Android, Mac, and Windows platforms with Visual Studio and Xamarin.