Перейти к содержимому

Почему в visual studio не показывает подсказки для unity

  • автор:

How to enable IntelliSense on Visual Studio when working with Unity

Madhawa Perera

‘IntelliSense’ is a code completion tool that is built into Microsoft Visual Studio. This is a question you might get during the early days of your Unity development. I see many ask this question during workshops. So thought of putting the steps into an article. If you wonder, when you are editing your scripts on Visual Studio, why some of the packages are not properly linked hence you cannot look into their implementation Or the autocompletion is not working as you see in many tutorials? Well, this is a very short article on how to solve this problem. For your additional information, ‘IntelliSense’ sometimes referred to as code completion or code assists as well.

Before diving into the steps, here are the versions of the tools that I am using in this article.

  1. Unity — Version 2019.3.15f1
  2. Microsoft Visual Studio Community 2019 — Version 16.7.1

The first step is if you have already opened your Visual Studio, close it. Then go to Unity and then go to Edit → Preferences… You will see the following window after you select the External Tools option on the left-hand side of the window. Refer to Figure 1

In this window, click on the drop-down in front of ‘External Script Editors’. Then select your favourite editor. Since I am using Visual Studio 2019, I selected that. Refer to Figure 2.

Also, I am gonna use the checkboxes below in .csproj files. Finally, the window settings looks like below in Figure 3

Now close this window and go to back to Unity project window and double click on the script that you were working on. Well, the problem should be solved.

Как включить подсказки для Unity в Visual studio?

Так как в версии 18 года любимую MonoDevelop больше не поддерживают, придется пользоваться VS. Все будет ничего, но подсказок как в моно нет, вернее есть но команд юнити там нет (Time, touch, PlayerPrefs и все остальное), как их включить? В VS code тоже их нет

Vefery's user avatar

Всё до банальности просто, достаточно установить расширения для Visual Studio для этого прожмите:

Средства -> Расширения и обновления. (Tools -> Extentions and Updates..)

В появившемся окне вбить в поисковике Unity.

Установить расширение. (Visual Studio 2017 Tools for Unity)

Но по идее без него должно было всё работать, вроде бы.

nipercop's user avatar

В Unity надо открыть: Edit -> Preferences, вкладка External Tools, в External Script Editor выбирать: Visual Studio 2017 Community.

0xdb's user avatar

Была такая же проблема при использовании VSCode в юнити 2019.2.11f, т.е. не отображались контекстные подсказки при вводе для классов, методов и т.д.

Как решил: 1) Делаем все в точности как описано в официальном мануале по интеграции VSCode с Unity https://code.visualstudio.com/docs/other/unity

2) Если все сделали по мануалу, у вас должен быть установлен VSCode с плагинами C# и Debugger for Unity, при этом в юнити в Edit\Preferences\External tools у вас выставлен VSCode(с установленными параметрами ProjectPath, File, Line, Column) как редактор скриптов и установлен флажок Editor Attaching. Далее, открываем любой скрипт из юнити — он должен открыться в VSCode и в окне Explorer-а должна отображаться вся структура вашего проекта( а не только файл открытого скрипта).

3)Плагин C# внутри VSCode должен выдать предупреждение в лог (консоль можно открыть в самом нижнем поле редактора VSCode слева внизу два значка — ошибка и предупреждение), что файл проекта подгружен некорректно из-за отсутствия необходимого пакета .Net Framework какой-либо версии (в моем случае это была версия 4.7.1, в вашем случае может быть другая)! Устанавливаем требуемый пакет .NET Framework с оф. сайта майкрософта (https://dotnet.microsoft.com/download/dotnet-framework) или откуда угодно, ДАЖЕ ЕСЛИ УСТАНОВЛЕНА БОЛЕЕ ПОЗДНЯЯ ВЕРСИЯ (это никак не повредит ей).

После установки .Net Framework закройте на всякий случай Unity(если изменяли состояние флажка Editor attaching) и VSCode. Откройте юнити заново и откройте любой скрипт. В этот раз при открытии файла плагин C# в VSCode больше не должен выдавать ошибок загрузки проекта и контекстные подсказки будут работать.

Visual studio code autocomplete/intelliSense not working fix for Unity

If you have installed Visual studio community along with Unity editor using Unity Hub then you can see that your Visual studio editor has autocomplete/IntelliSence enabled by default. That is, you will be able to see all Unity functions as you type. But if you have installed Visual studio code then you might not see the autocomplete in the editor. So, in this section of learning Unity, we will see how to set up autocomplete in VScode.

The solution varies based on the Unity version. So if you are using Unity 2020 or older, use the first method and for 2021 or newer, use the 2nd solution.

VScode is both language and framework independent. You will need to install the required dependencies to solve this problem.

Unity autocomplete in VScode

Step by step procedure to enable IntelliSence in VScode

For Unity 2020 or older

  1. Close both Unity and VScode.
  2. If you are on Windows, Download and install .NET framework 4.7.1Developer Pack. If you are on Mac, then download .NET SDK and mono stable release.
  3. Open Unity.
  4. Go to Edit>Preferences>External tools.
  5. Select Visual studio code as your external script editor.
  6. In the external script editor Args box enter “$(ProjectPath)” -g “$(File)”:$(Line):$(Column)
  7. Click on regenerate project files.
  8. Go to Window>Package Manager. Under Unity registry, find Visual Studio code editor and install the package if not installed already.
  9. Open Visual studio code.
  10. Install C# for Visual Studio Code (powered by OmniSharp) extension.
  11. Close VScode.
  12. Open VScode from Unity. Now IntelliSence should work and syntax should autocomplete.

Now we are ready to get started with scripting in Unity.

For Unity 2021 or newer

Microsoft has launched a new extension for VScode to work with Unity 2021 and newer. Use the following steps to make the extension work with Unity.

Open Vscode and add the C# dev kit extension and Unity extension(by Microsoft).

Unity extension for VScode.

Close VScode and open Unity editor. Go to Window>Package Manager.

Search for Visual Studio Editor package(not Visual Studio Code package)

It will be pre-installed but you have to update it to version 2.0.20.

After Updating, close package manager and go to Edit>Preferences>External Tools.

Select Visual Studio Code as your script editor.

Restart Unity and now if you open any Unity script in VScode, you will have auto complete activated.

ПОЧЕМУ VISUAL STUDIO НЕ ПОДСКАЗЫВАЕТ UNITY

Возможны несколько причин, почему Visual Studio не подсказывает Unity. Одна из них может быть неправильная настройка среды разработки. Возможно, необходимо установить или обновить плагины и расширения, связанные с Unity. Также, возможно, нужно проверить правильность конфигурации проекта Unity, чтобы Visual Studio мог обнаружить его и предоставить подсказки и автодополнение. В некоторых случаях, это может быть связано с обновлением самой Visual Studio или Unity, поэтому важно проверить их совместимость. Если обычные решения не помогли, то стоит обратиться к сообществу разработчиков Unity или официальным источникам для получения дополнительной информации и решения проблемы.

Как исправить ошибку связанную с Unity движком

Visual Studio не подсказывает в Unity #shorts #unity #unity3d

Ошибка #2 — Visual Studio не подсвечивает код из Unity

Научу создать игру на Unity за 5 минут. — Gamicle

Unity\\C#: Установка unity, visual code, visual studio. Исправление ошибок

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *