Unity Intellisense doesn't work(Solution1, Miscellaneous Files issue)

Viewed 14157

I can't use Intellisense in visual studio. When I double-click a c# file in Unity, visual studio shows up. But on top, I can't see my project name. Instead there is "Miscellaneous Files". So Intellisense doesn't work.

What I've already tried:

1

I opened the external script editor, it was default "open by file extension". I changed it to vs 2017 and vs 2019. But this time when I open my scripts from Unity, it doesn't open. So I changed it back to "open by file extension".

2

I controlled the visual studio tool for Unity. I already downloaded it.

3

In solution explorer, right clicked and added "RegularFight.sln" again. Nothing changed but then clicked folder view. And I can use Intellisense. But this is temporary. I have to do this everytime.

4

Show the project on explorer. There is "RegularFight.sln" which is my projects name and which is 1KB. So it means it's an empty solution. And there is "Assembly-CSharp.csproj" it's 45KB and it includes my scripts. When I open it I can use Intellisense.

So I want to use Intellisense when I open my script from Unity. How can I fix it?

Unity version: 2020.1.7f1
3 Answers

Seeing "Miscellaneous Files" means that your Visual Studio is not properly synced with Unity. You're seeing just a plain old C# file by itself, not a file that is associated with a Project.

The steps to rectify are usually:

  1. Make sure "Visual Studio Editor" ( a.k.a. Visual Studio Tools for Unity) is installed in Package Manager.
  2. Go to Edit > Preferences > External Tools and make sure that Visual Studio is set as your "External Script Editor".
  3. Restart both Unity and Visual Studio, or even your whole machine to make sure.

Here's what you should be seeing (or something similar depending on your Unity version).

Package Manager and the Visual Studio Editor package

And your preferences should look similar to this:

enter image description here

After making sure all these items are in place, 9 times out of 10, that will resolve your issue.

You also don't want to be adding or touching .SLN (solution files) directly. Unity will add all of the projects and references required to the solution file. Any changes you make will generally be overwritten by Unity.

After doing all the normal steps, try reloading the project in Visual Studio, within the Solution Explorer. (if you're able to open VS, of course)

Related