I recently installed the Unity Extension for Visual Studio Code and configured my Unity project to use VSCode. It’s working seamlessly, except for one problem. If there are compilation errors in C# scripts, the errors are displayed in the Unity console, but are hidden in VSCode until you open the file containing the errors. With the old Unity package, every C# file containing errors would have their name highlighted in red automatically. With the new configuration, the filenames are displayed in white (or whatever the there-are-no-problems color is) until the file is opened, when the errors are detected and displayed in the editor and directory hierarchy.
Is there any way to configure Unity Extension for Visual Studio Code to indicate errors before opening the files?
Unity VS Code support has been deprecated, but then very recently a new package was announced or released as experimental/preview I think. So it matters which of these you are using.
Generally speaking I always recommend to stay clear of VSCode for Unity work, especially if you are a) a beginner because you get to have issues you needn‘t have for which you get little to no help and b) professionals as you will waste time (aka money) fighting issues few other people have and lack of tool support slowing down development, greatly offsetting the few seconds saved on launching VSCode compared to VS.
VSCode has some merits on OSX and is certainly useful on Linux.
Yeah I share my opinion here and there mainly in an effort to keep the number of foolish VSCode users to a minimum. At least until it‘s actually mature and MS has shown they really mean it this time (perhaps more so than their VS support for Unity).
That sure looks like it should fix the problem, but sadly it doesn’t. I changed those settings for both User and Workspace. The errors still don’t get detected until you open the files.
What additional information should I provide to assist with figuring this out?
Building yields very inconsistent results. After waiting for minutes, it finds lots of errors, none of which are cited in Unity. The following were found when my project contained no errors…
I redownloaded my project from SCM to start from a clean slate. VS Code is finding compilation problems, although inconsistently. Here are some variants I’ve seen…
A few legit warnings are found along with 20 or so others that are not cited by Unity. This happens more often than not.
Hundreds of errors are cited having to do with items in my various script subdirectories not being found. None of the errors are cited by Unity.
Hundreds of errors are cited having to do with System.Void, System.int32, etc. not being found. None of the errors are cited by Unity.
What it never finds is my little syntax error, unless I open the file that it’s in.
I had both of these problems and I fixed them by setting both of the Background Analysis options in VS Code to fullSolution, updating the visual studio editor package in Unity, updating to .NET 8.0, deleting all of the files alongside the .csproj files in my projects root directory, and then regenerating project files with only the first two boxes checked under ‘Generate .csproj files for:’.
This has worked so far, though it takes a while for the error console to update for whatever reason.