This Unity project was not generated for the Visual Studio Tools for Unity error.

Hi!

I have been making my multiplayer game using Photon Pun 2 for some time now, but suddenly now when I opened Visual Studio there was a text saying: This Unity project was not generated for the Visual Studio Tools for Unity. In your Unity Editor, please go to Preferences > External Tools and select Visual Studio for a better experience.

At the same time I got many errors because Visual Studio did not recognize the namespace Photon.Pun anymore. I tried fixing this by updating Photon from the unity package manager and by updating Visual Studio to a newer version (when doing this Visual Studio warned me for using .Net core version 2.1). This didn’t help at all and I still have the same issue.

I went to unity preferences > external tools and the external script editor was set to Visual Studio Community 2019 [16.11.7] and the other options were open by file extension and browse. In the external tools menu there were many options for generating .csproj files for. From those I have checked embedded packages and local packages.

In the package manager where I downloaded Pun 2 there was still the import button visible even though I think I have all the photon stuff required. I was scared of Photon stuff breaking if I press the import button so I didn’t do it. Also I didn’t see the Pun 2 in the in project section of the package manager.

I also opened Visual Studio in another project and I didn’t get the This Unity project was not generated for the Visual Studio Tools for Unity error.

I’d greatly appreciate any help! and sorry for my bad english.

I have the same problem since I changed to Visual Studio 2022 from 2019 recently;

  • Installed VS Studio 2022 including the Unity development tools
  • Set external Script editor to VS studio 2022 in preferences/External script editor
  • same settings ticked in preferences : embedded and local packages

'This Unity project was not generated for the Visual Studio Tools for Unity. In your editor go to preferences > external tools and select Visual Studio foa a better experience.

  • Regenerating project files doesn’t solve this.
  • When I change back to VS 2019 in preferences/External script editor, no error msg.

Anybody got any idea why this is happening?

I fixed the issue by regenerating project files

For anyone else running into this, I was able to skirt around the issue by just leaving the editor set to 2019 community (Edit → Preferences → External Tools), regenerating the project files in unity, and then manually opening the .sln file with 2022.

For me, the problem was that I had the wrong package installed in Unity. I had “Visual Studio Code Editor” installed instead of “Visual Studio Editor”. Once I got the correct one installed and re-opened my scripts, the alert message was gone.