Visual Studio IntelliSense autocomplete ceases to work after creating a new script

I’ve been having a frustrating issue where whenever I create a new script in my Unity project (which I do by right-clicking my Assets\Scripts folder within the Unity editor and selecting CreateC# Script), Visual Studio’s IntelliSense stops working. Visual Studio will forget anything related to UnityEngine after I create a new script (for example, it won’t autocomplete ScriptableObject or gameObject).

This affects all scripts, not just the newly created script. For instance, if I have an existing file open, create a new script in Unity, and go back to Visual Studio without even opening the newly created file, IntelliSense does not work even in the pre-existing file (or any other file, be it a pre-existing file or the new one).

This is fixed on restarting Visual Studio, but given it’s a recurring issue that occurs, without fail, every time I create a new script in my Unity project, it’s an issue that is hampering my workflow, and I would greatly appreciate any help in solving this.

I’ve looked around on the web for answers, but I’ve only managed to find a couple people with the same issue. Two of the posts are old and with developer replies saying it’s been fixed. One was about VSCode, not VS. One is recent and relevant, and on Reddit, but has no answers. Perhaos it’s an issue with a recent version of Visual Studio; I’m not sure.

– Versions –
Unity editor: 2022.3.47f1 (LTS)
Visual Studio: 17.11.5 (same issue with 17.11.4)
OS: Windows 11 Home 23H2
Visual Studio Editor package: 2.0.22

– Steps to Reproduce –
• Open Visual Studio and verify that IntelliSense works.
• Create a new C# script in Unity.
• Wait for it to reload and complete the domain.
• Check if IntelliSense still works in Visual Studio.

– What I’ve tried –

  1. Checked PreferencesExternal Tools:

  2. Clicked ‘Regenerate project files’.

  3. Updated Visual Studio to the latest version.

  4. Checked if I can update the Visual Studio Editor package (I cannot).

Happens all the time, 100% of the time after every new file is created in Unity.

Alas.

Sometimes the fix is as simple as doing Assets → Open C# Project from Unity. Other times it requires more.

This may help you with intellisense and possibly other Visual Studio integration problems:

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: No suggestions in Vscode - Unity Engine - Unity Discussions

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.

Thanks. I’ve seen this answer on other posts. I’ve already tried these solutions as mentioned in my post. Clicking Assets → Open C# Project won’t fix it unless I restart C#. The solutions in the first thread you linked have not worked for me. I already have Visual Studio set as my external editor in the Unity settings as shown in the screenshot in my post, and I couldn’t find an option called ‘Editor Attaching’.

The other threads you linked are related to VSCode, not Visual Studio, and I’m working with Visual Studio.

I’been struggling with this bug for a week and I got mad, looking for a solution. I tried a lot but can’t find any solution, I think it is on Visual Studio side and this bug happens at 17.10 version but good news I have alternative solution for you guys:
-Close your Unity Project, delete .vs folder (if you can’t see it’s hidden folder) .sln and all .csproj files
-I removed Visual Studio completely from computer through Visual Studio Installer
-Go to google for Visual Stuio Download then download the “VisualStudioSetup.exe”
-Now we will install the 17.8 version of the Visual Studio
visualstudiosetup.exe --channelUri https://aka.ms/vs/17/release.LTSC.17.8/channel
-Visual Studio Installer will be started and start installation of the 17.8 version
-Go to Unity->Edit->Preferences->External Tools->External Script Editor-> Select Visual Studio 2022[17.8…] if it’s not selected.

Thank you so much! Hours of scouring the web yielded no solutions, and you came in clutch with something that actually worked!

After uninstalling Visual Studio and installing 17.8 using the command you provided, I’ve verified that this bug no longer occurs. It’s clearly an issue with newer versions of Visual Studio 2022.

Hopefully this can be fixed. Perhaps this should be posted on the Visual Studio forums, although I’m unsure whether it’s something that is caused or could be fixed in Unity or whether it’s purely a Visual Studio issue.

Fixed in VS 2022 17.12 Preview 3 Build: Developer Community

Glad to hear that! I’ll wait on updating till it’s implemented into the stable release. Thanks for notifying me!