0
\$\begingroup\$

After every Unity update I have a lot of problem with missing assemblies in Visual Studio Code.

The type or namespace name "UI" does not exist in the namespace "UnityEngine"

But after some messing around, somehow it always becomes fixed. I updated Unity again and now after wasting hours I decided to do it the right way and find out the source of the problem.

As it turns out the problem is simply that the .sln generated when the external editor is VS Code is just simply missing a lot of assemblies: (and its icon is VS10 instead of VS15) enter image description here

Here's the full difference: Link

If I switch the external editor to VS Studio and click Regenerate Project Files, the .sln is now full of assemblies. (if I would just switch to it, it wouldn't touch the sln)

So now I switch back to VS Code, voilá it works because the assemblies are in the .sln.

BUT for some reason if I restart Unity the .sln is always regenarated because possibly it detects that it has been generated by VS Studio while the current editor is VS Code.

So it's missing the assemblies every time I restart Unity.

Now at least I know that every time I launch Unity,

  1. I have to switch to VS Studio,
  2. click Regenerate Project Files,
  3. and then switch to VS Code.

But before the update it was fine. It's always like this and then somehow it becomes fixed automatically at startups as well.

What's causing this, how could I fix it? Thanks in advance!

\$\endgroup\$
2
  • 1
    \$\begingroup\$ This looks like a bug to report to Unity's development teams. \$\endgroup\$
    – DMGregory
    Commented Sep 30, 2021 at 11:47
  • \$\begingroup\$ I've already sent a bug report and opened a forum thread for this issue, but I created this question as well, hoping that someone may know the answer here. :) \$\endgroup\$
    – Tudvari
    Commented Sep 30, 2021 at 12:15

1 Answer 1

1
\$\begingroup\$

Finally Unity answered:

Looking at the file structure of this project, it seems that .csproj files are enabled to be generated for many packages.

So they suggested the following fix which indeed solved it:

  • In the Unity editor, with the broken project opened, navigate to Edit > Preferences... > External Tools.
  • Under "Generate .csproj files for:", uncheck any checked boxes.
  • Click "Regenerate project files".
  • Restart VS Code.

And for some reason I can still access my git packages in my IDE so then I don't know what "Git packages" checkbox is for.

enter image description here

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .