I have been having this issue for a very long time but i has been manageable up until now. Whenever im in visual studio working on some code, occasionally it would hitch slightly and then my intellisense would stop working. Irritating, but it wouldn’t break anything, the code would still work, i could still reference it from other scripts etc.
The only way to fix it was to ctrl a copy everything, delete the file, create a new file with the same name and past it all in back in. Annoying, but manageable for one file. I have tried other things, restarting unity, regenerating project files etc but none of that worked.
I was working on some code just now and the same thing happened. I copied all the code and went back to unity to delete the file and recreate like i normally do, but i noticed dozens of compilation errors in the console. The files that broke are no longer visible to anything in the project, not just causing syntax highlighting to break. I clicked on the first error, it brings me to code that calls a static utility method i have, but is saying that the class its calling doesn’t exist.
Typically this would happen maybe a few times, once an hour if im really unlucky, but this has happened multiple times with multiple files in a 10 minute span, breaking not only the file that i opened, but the entire assembly or folder it was in.
Why is this happening and how can i fix it? I have tried closing unity, regenerating project files and everything and it doesnt work.
as long as you’re using studio and not visual studio code - not to be confused. You need to have the unity tools installed from the studio end, and you need the visual studio package, and maybe to regen the csproj files.
I have both installed. I installed visual studio with unity and the Game Development with Unity option and i have the visual studio package installed in the package manager.
Sometimes you have to nuke it all (uninstall it all) and start over. That’s rare, but I’ve had to do it once in a while.
Usually if you nuke all the silly Visual Studio crap (csproj, sln, usersettings, .vs and .vsconfig), then reopen, it will work again… until it fails again.
Here’s my complete list:
This may help you with intellisense and possibly other Visual Studio integration problems:
Sometimes the fix is as simple as doing Assets → Open C# Project from Unity. Other times it requires more.
Other times it requires you also nuke the userprefs and .vsconfig and other crufty low-value high-hassle files that Visual Studio tends to slowly damage over time, then try the above trick.
Barring all that, move on to other ideas:
Also, try update the package inside of Unity: Window → Package Manager → Search for Visual Studio Editor → Press the Update button
Depending on flavor and version of Visual Studio, it may also have an installation step that you perform within the actual Visual Studio. This step seems finicky at best and may require multiple openings of VS before it comes up.
Update: The VSCode extension has been deprecated and abandoned:
Update: the VSCode integration is back… maybe!?
There may be a community fork available that is receiving updates.
Also, this tidbit:
Recently (July 2023) I worked on a Windows11 system that required a Microsoft component to be installed from within Visual Studio before it would work properly with all the OTHER software installed under Unity. I have no documentation on that process as I have only seen it once and it surprised me as well.
I updated visual studio but it didn’t appear to help. I uninstalled unity and VS and reinstalled and it worked. It is very annoying that this is happening so frequently. Thanks.
I don’t work on this aspect but Unity doesn’t store “Intellisense” in itself or its installation so reinstalling Unity shouldn’t have any effect; it doesn’t control it at all. If it’s failing, it’s all Visual Studio. It’s more likely uninstalling and reinstalling causes your project library to be updated when you load it again.
That said, Unity cannot compile your script if it has compilation errors so everything at that point is stale with the script assemblies in an unknown state. You must do your add/remove/rename changes as much as possible in Unity and not manually with the file-system or VS.
All the “Intellisense” information about your project is gathered by Visual Studio and all that information cached or otherwise is in your assets project folder (scripts) and more importantly the “Library” folder so I’d say nuke the “Library” folder if you have to. You can also do a minimum delete to see if it helps by deleting “Library/ScriptAssemblies”. Obviously all this has to be done without the project loaded. In some cases Unity can detect corruption here (you may occasionally see this) but not always.
Essentially external tools such as Visual Studio or Rider use the cached assemblies and also create their own cached folders too so just remove those, they’ll be regenerated and in some cases fix issues like this.
This is why having it under source control such as Git can be important. If I ever get this, a quick git clean -dfx sorts it out.