Quickstart: Configure Visual Studio for cross-platform development with Unity
In this quickstart, you learn how to install the Visual Studio Tools for Unity extension and configure it for developing cross-platform games and apps with Unity. The Visual Studio Tools for Unity extension is free and provides support for writing and debugging C# and more. Visit the Tools for Unity overview for a complete list of what that workload includes.
Install Visual Studio and Unity
- Download the Visual Studio installer, or open it if already installed.
- Select Install, or Modify if Visual Studio is already installed.
- Select the Workloads tab, then select the Game development with Unity workload.
- If Unity isn’t already installed, select Unity Hub under Optional.
- Select Modify or Install to complete the installation.
When Visual Studio completes the installation process, you’re ready to set up Unity.
- Open the Unity Hub, which was installed during the Visual Studio Tools for Unity installation.
- On the left of the Unity Hub window, select the Installs tab.
- Select the Add button.
- In the Add Unity Version window, select a version of Unity to install.
- Select Next to continue the installation.
- In the Add modules to your install step, select Done.
Note If you’ve already installed Visual Studio 2022, you can deselect the Microsoft Visual Studio Community 2019 option.
The Unity Hub continues installing Unity in the background. When it’s complete, you can create a new project by selecting the Projects tab and selecting New.
Projects are created using the Unity Editor and not Visual Studio.
This installation guide is for Visual Studio for Mac. If you’re using Visual Studio Code, please visit the Unity Development with VS Code documentation.
Visual Studio for Mac Tools for Unity is included with the installation of Visual Studio for Mac. It requires no separate installation steps. You can verify the installation in the Visual Studio for Mac > Extensions > Game Development menu. Visual Studio for Mac Tools for Unity should be enabled.
Configure Unity to use Visual Studio
By default, Unity should already be configured to use Visual Studio or Visual Studio for Mac as a script editor. You can confirm this option or change the external script editor to a specific version of Visual Studio from the Unity Editor.
- In the Unity Editor, select the Edit > Preferences menu.
- On the left, select the External Tools tab.
Add a version of Visual Studio that isn’t listed
It’s possible to select other versions of Visual Studio that are unlisted and installed in a custom directory.
- Select Browse. from the dropdown list.
- Navigate to the Common7/IDE directory inside your Visual Studio installation directory and select devenv.exe. Then select Open.
- For Unity 2019 and older only, confirm that Editor Attaching is selected.
- Close the Preferences dialog to complete the configuration process.
- In the Unity Editor, select the Unity >Preferences menu.
- On the left, select the External Tools tab.
- Use the External Script Editor dropdown list to choose different installations of Visual Studio for Mac.
- Close the Preferences dialog to complete the configuration process.
Install or update the Visual Studio Editor package
In Unity versions 2020 and later, a separate Unity Package is required for the best experience working with IDEs like Visual Studio and Visual Studio for Mac. This package should be included by default, but updates are released to this package that you can install to at any time.
- In the Unity Editor, select the Windows >Package Manager menu.
- Select the Visual Studio Editor package.
- If a new version is available, select Update.
In Unity versions 2020 and later, a separate Unity Package is required for the best experience working with IDEs like Visual Studio and Visual Studio for Mac. This package should be included by default, but updates are released to this package that you can install to at any time.
- In the Unity Editor, select the Windows >Package Manager menu.
- Select the Visual Studio Editor package.
- If a new version is available, select Update.
Check for updates
We recommend that you keep Visual Studio and Visual Studio for Mac updated for the latest bug fixes, features, and Unity support. Updating Visual Studio doesn’t require an update of Unity versions.
- Select the Help >Check for Updates menu.
- If an update is available, the Visual Studio Installer shows a new version. Select Update.
- Select the Visual Studio for Mac >Check for Updates. menu to open the Visual Studio Update dialog.
- If an update is available, Visual Studio Update shows a new version, select Restart and Install Updates.
Install queued unity что делать
Класс Queue представляет обычную очередь, которая работает по алгоритму FIFO («первый вошел — первый вышел»).
Создание очереди
Для создания очереди можно использовать один из трех ее конструкторов. Прежде всего можно создать пустую очередь:
Queue people = new Queue();
При создании пустой очереди можно указать емкость очереди:
Queue people = new Queue(16);
Также можно инициализировать очередь элементами из другой коллекции или массивом:
var employees = new List < "Tom", "Sam", "Bob" >; Queue people = new Queue(employees); foreach (var person in people) Console.WriteLine(person); Console.WriteLine(people.Count); // 3
Для перебора очереди можно использовать стандартный цикл foreach .
Для получения количества элементов в очереди в классе определено свойство Count .
Методы Queue
У класса Queue можно отметить следующие методы:
- void Clear() : очищает очередь
- bool Contains(T item) : возвращает true , если элемент item имеется в очереди
- T Dequeue() : извлекает и возвращает первый элемент очереди
- void Enqueue(T item) : добавляет элемент в конец очереди
- T Peek() : просто возвращает первый элемент из начала очереди без его удаления
Посмотрим применение очереди на практике:
var people = new Queue(); // добавляем элементы people.Enqueue("Tom"); // people = < Tom >people.Enqueue("Bob"); // people = < Tom, Bob >people.Enqueue("Sam"); // people = < Tom, Bob, Sam >// получаем элемент из самого начала очереди var firstPerson = people.Peek(); Console.WriteLine(firstPerson); // Tom // удаляем элементы var person1 = people.Dequeue(); // people = < Bob, Sam >Console.WriteLine(person1); // Tom var person2 = people.Dequeue(); // people = < Sam >Console.WriteLine(person2); // Bob var person3 = people.Dequeue(); // people = < >Console.WriteLine(person3); // Sam
Стоит отметить, что если с помощью методов Peek или Dequeue мы попытаемся получить первый элемент очереди, которая пуста, то программа выдаст исключение. Соответственно перед получением элемента мы можем проверять количество элементов в очереди:
if(people.Count > 0)
Либо можно использовать пару методов:
- bool TryDequeue(out T result) : передает в переменную result первый элемент очереди с его удалением из очереди, возвращает true , если очередь не пуста и элемент успешно получен.
- bool TryPeek(out T result) : передает в переменную result первый элемент очереди без его извлечения из очереди, возвращает true , если очередь не пуста и элемент успешно получен.
var people = new Queue(); // добавляем элементы people.Enqueue("Tom"); // people = < Tom >// удаляем элементы var success1 = people.TryDequeue(out var person1); // success1 = true if (success1) Console.WriteLine(person1); // Tom var success2 = people.TryPeek(out var person2); // success2 = false if (success2) Console.WriteLine(person2);
Очереди — довольно часто встречаемая стуктура в реальной жизни. Например, очередь пациентов на прием к врачу. Реализуем данную ситуацию:
var patients = new Queue(); patients.Enqueue(new Person("Tom")); patients.Enqueue(new Person("Bob")); patients.Enqueue(new Person("Sam")); var practitioner = new Doctor(); practitioner.TakePatients(patients); class Person < public string Name < get; >public Person(string name) => Name = name; > class Doctor < public void TakePatients(Queuepatients) < while(patients.Count >0) < var patient = patients.Dequeue(); Console.WriteLine($"Осмотр пациента "); > Console.WriteLine("Доктор закончил осматривать пациентов"); > >
Здесь класс врача — класс Doctor в методе TakePatients принимает очередь пациентов в виде объектов Person. И пока в очереди есть объекты извлекает по одному объекту. Консольный вывод:
Осмотр пациента Tom Осмотр пациента Bob Осмотр пациента Sam Доктор закончил осматривать пациентов
Installing Unity using the Hub
The Unity Hub is a management tool that allows you to manage all of your Unity projects and installations. Use the Hub to manage multiple installations of the Unity Editor along with their associated components, create new Projects, and open existing Projects.
Installing the Unity Hub
To install the Unity Hub, visit Download Unity Personal on the Unity website,
To install and use the Unity Editor, you must have a Unity Developer Network (UDN) account. If you already have an account, sign in and proceed to the Installing the Unity Editor section.
If you do not have an account, follow the prompts to create one. You can choose to create a Unity ID, or use one of the social sign-ins. For more information on accounts and subscriptions, see Unity Organizations.
Installing the Unity Editor
To install the Editor:
-
Click the Installs tab. The default install locations are: Windows:
C:\Program Files\Unity\Hub\Editor
/Application/Unity/Hub/Editor
- Optionally, to change the default installation location, click the Gear icon.
- In the Editor Folder Location dialog box, enter the new installation location and click Done.

If you are installing multiple Editor versions, the first installation starts as soon as the download is complete. Other selected versions download simultaneously and queue to start when the current installation finishes.
The Hub displays the installation location of each Editor under the corresponding version label.
To set it an Editor version as your preferred version, add components to it, or uninstall it, click the three dots next to that Editor version.
If you remove or uninstall the preferred Editor version, another installed Editor version becomes the preferred version.
Adding existing instances of the Editor to the Hub
You can add instances of the Editor to the Hub that you installed outside of the Hub.
- Click the Installs tab.
- Click the On my machine tab. To find existing installations of the Editor, click Locate a Version.
- In the file dialog, navigate to the location of the Editor installation and select the Unity executable. On MacOS this is Unity.app. On Windows this is Unity.exe.
On macOS, the path is typically:
/Applications/Unity/Hub/Editor//Unity.app
On Windows, the path is typically:
C:\Program Files\Unity\Editor\Unity.exe
C:\Program Files\Unity\Editor\Unity.exe
- Click the Select editor button.
To set the Editor as the preferred version, or to remove the Editor from the Hub, click the three dots next to the Editor version.
Removing an Editor that you added in this manner does not uninstall it or modify it in anyway.
Support for Editor versions prior to 2017.1
Sign in status is not shared for pre–2017.1 versions of the Editor opened through the Hub. Performing tasks such as Manage License, Open Project, Create Project, and Sign in opens the Unity Launcher instead of the Hub.
If you attempt to use the Unity Hub to open an Editor version 5 or earlier and you do not have an appropriate license file, the Editor will hang on the splash screen.
To avoid this issue, run the Editor directly, external to the Unity Hub, and the Editor will load correctly even if the license file is not detected.
2018–06–12 Page published with editorial review
Unable to install any Unity version from Unity Hub
I’m looking into learning to use Unity, so I’ve downloaded the Unity Hub as it seems to be the way Unity is forcing us to download their versions from now on. The problem with this is that, every time I try to download any version of Unity through the Hub, I get a message once the download bar has completed along the lines of: «Incomplete or corrupt download». I’ve tried downloading plenty of different official versions, with various plugins, even without any add ons to start with, but I always get the same message. I contacted Unity support, but they’re insisting that it’s my internet connection and I should download versions from the archives. Surely this can’t be the case, as I can download everything else without any issues. Has anyone else come across this issue and are there any solutions out there?
asked Dec 8, 2019 at 17:19
11 1 1 gold badge 1 1 silver badge 2 2 bronze badges
did you try downloading manually, just to see if the installer works? (since it downloads those files from web also) unity3d.com/get-unity/download/archive (select dropdown: downloads/unity installer)
Dec 9, 2019 at 12:43
Hey everyone. Sorry for the late reply on this. Had to take some time away from learning this. I’ve installed Unity Hub version 2.3.2 and the issue seems to be fixed. In the meantime, I had taken the advice and manually installed Unity without using the Hub. Thanks a lot for the help!