Была такая же проблема при использовании VSCode в юнити 2019.2.11f, т.е. не отображались контекстные подсказки при вводе для классов, методов и т.д.
Как решил:
1) Делаем все в точности как описано в официальном мануале по интеграции VSCode с Unity
https://code.visualstudio.com/docs/other/unity
2) Если все сделали по мануалу, у вас должен быть установлен VSCode с плагинами C# и Debugger for Unity, при этом в юнити в EditPreferencesExternal 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 больше не должен выдавать ошибок загрузки проекта и контекстные подсказки будут работать.
P.S. дополнение VSCode integration для Unity из Asset Store можно не устанавливать, т.к. если все сделано правильно, то все работает и без него.
У самого такая проблема. Насколько я помню, ассет для интеграции VS Code с Unity уже deprecated и больше не работает (либо с современными версиями Unity, либо с новыми версиями VS Code), а также его разрабы уже забили на него .
Я месяцами пытался найти решение, но так ничего и не получилось.
Если у тебя слабый PC и ты просто хочешь норм IDE, то ты можешь скачать 2017 версию Unity и пользоваться прекрасным Monodevelop (если ты только изучаешь Unity, для работы с настоящими проектами я бы выбрал версию 2020 года с Visual Studio).
I’m using VS Code and Unity, and I noticed that errors are showing on Unity console but not the VS Code, I looked up and did everything that this page says and nothing worked: https://code.visualstudio.com/docs/other/unity
Is there a fix to this?
asked Mar 7, 2022 at 20:47
5
I had this problem too. One day Code’s errors were connected, the next day, they had disappeared. Most frustrating. This worked for me:-
- Install the latest .net SDK from here DotNet SDK download
2) Regenerate project files from Edit->Preferences->External Tools
Note: just regenerating the project files didn’t work for me. Needed DotNet SDK update.
answered May 30, 2022 at 11:42
Mikey BallyMikey Bally
4444 silver badges7 bronze badges
0
The official doc is wrong https://code.visualstudio.com/docs/other/unity
step 5 : In the VS Code Settings editor (Ctrl+,), uncheck the C# extension’s Omnisharp: Use Modern Net setting («omnisharp.useModernNet»: false)
You need to do the exact opposite and check it.
answered Mar 28 at 11:21
flo floflo flo
1661 silver badge8 bronze badges
Сообщений: 3 • Страница 1 из 1
Редактор Visual studio не показывает ошибки [решено]
NOVA 18 сен 2022, 18:05
Не показывает ошибки в коде. Типа двойное объявление переменной, грамматические ошибки, пропуски точки запятой. То есть вообще ничего не показывает, пока скрипт не откомпилируется в unity. И ошибки уже видно в консоли.
Как быть?
Последний раз редактировалось NOVA 18 сен 2022, 19:54, всего редактировалось 3 раз(а).
-
NOVA - Адепт
- Сообщения: 1722
- Зарегистрирован: 17 май 2011, 11:45
- Откуда: Дядя Саша from Mother Russia
Re: Редактор Microsoft visual studio 2019
1max1 18 сен 2022, 19:28
preferences — ex. tools. — ex. scr. editor — vs 2019
-
1max1 - Адепт
- Сообщения: 5430
- Зарегистрирован: 28 июн 2017, 10:51
Re: Редактор Microsoft visual studio 2019
NOVA 18 сен 2022, 19:52
Спасибо. Заработало.
Подробнее:
Unity -> Edit -> Preferences -> External tools -> Visual Studio Community 2019 [16.11.16]
Всё закрыть и заново открыть.
-
NOVA - Адепт
- Сообщения: 1722
- Зарегистрирован: 17 май 2011, 11:45
- Откуда: Дядя Саша from Mother Russia
Сообщений: 3 • Страница 1 из 1
Вернуться в Почемучка
Кто сейчас на конференции
Сейчас этот форум просматривают: Google [Bot] и гости: 32
How to enable Unity warnings in Visual Studio Code
Visual Studio ships Unity analyzers out of the box, which trigger custom warnings when something looks wrong with your C# code. If you are using Visual Studio Code, however, you will need to set these up manually to get the same warnings.
Begin by following this guide to configure Unity to run with Visual Studio Code.
Due to how Unity handles its .csproj
files, it does not seem possible to install packages automatically. You will need to download the analyzers from the NuGet website manually. When you’re done, open the package file using a tool such as 7zip and extract Microsoft.Unity.Analyzers.dll
onto your project’s root folder. You can place it inside a folder named NuGet
, for example. Do not place it inside Assets
or Packages
, as that will cause Unity to try to process the .dll
which will make it output an error in the console.
Next, create an omnisharp.json
file at the root folder of your project, as explained here. Analyzer support in Omnisharp is experimental at the moment, so we need to enable it explicitly. We also need to point it to the .dll
file we just extracted. Your omnisharp.json
file should end up looking like this:
{ "RoslynExtensionsOptions": { "EnableAnalyzersSupport": true, "LocationPaths": [ "./NuGet/microsoft.unity.analyzers.1.9.0" ] } }
Where "./NuGet/microsoft.unity.analyzers.1.9.0"
is a relative path pointing to the folder containing the .dll
file. Depending on where you placed it, your path may look different.
Congratulations! The Unity analyzers should now be working in your project. You can test them by creating an empty FixedUpdate()
method inside one of your MonoBehavior
classes, which should trigger a The Unity message 'FixedUpdate' is empty
warning (UNT0001).
Note that while it is possible to activate these analyzers, the supressors they ship with the package (that turn off other C# warnings that may conflict with these custom ones) may not be picked up by Omnisharp at the moment, according to this thread. You can still turn off specific rules manually, by following these steps:
-
Create a
.editorconfig
file in your project’s root folder (next to Unity’s.csproj
files) -
Add the following contents to the file:
root=true [*.cs] dotnet_diagnostic.IDE0051.severity = none
root=true
tells Omnisharp that this is your project root and it should stop looking for parent .editorconfig
files outside of this folder.
dotnet_diagnostic.IDE0051.severity = none
is an example of turning off the analyzer with ID IDE0051
by setting its severity level to none
. You can read more about this here. You can add as many of these rules as you wish to this file.
[*.cs]
indicates that our custom rules should apply to all C# scripts (files with the .cs
extension).
Thanks for your attention and if this was useful to you consider following me on Twitter!