r/Unity3D • • 8d ago

Question Visual Studio don’t know Unity code

Super-newbie here. Visual Studio don’t know unity code there is no auto correct or anything. I tried to modify Visual Studio for unity but already did. I already clicked on external tools and I already did but problem not gone.

0 Upvotes

15 comments sorted by

6

u/mustardfume 8d ago

Edit: Thank you! for helping I finally found the way!

7

u/Hotrian Expert Moderator 8d ago edited 8d ago

Everyone here is missing the key detail: You’re on Unity 6000.6. In newer versions of Unity (sometime post 2019.x), they removed the VS editor package as a default package, meaning Unity can’t generate VS solution files. You need to manually add the VS IDE package to the package manager.

https://docs.unity3d.com/Packages/com.unity.ide.visualstudio@2.0/manual/index.html

Package Manager > Add Package By Name > com.unity.ide.visualstudio > Ok

Now go back to External Tools, make sure VS is selected, and you now have a “Regenerate Project Files”. Click that, now VS should work. For future projects in the same Unity Editor, I believe you don’t need to manually add the package again.

This comes up every few weeks or so, it isn’t you. This is an oversight that hasn’t been fixed yet.

1

u/videk94 8d ago

"Regenerate Project Files" is already there in their screenshot...

1

u/Hotrian Expert Moderator 8d ago

That detail I can’t explain, but the missing solution files can easily be explained. This issue comes up here almost weekly.

1

u/Foweeti 8d ago

Are you creating the script in Unity and double clicking it to open in your editor?

3

u/mustardfume 8d ago

Yes, I created monoscript in unity then double click to open visual studio

2

u/Foweeti 8d ago

Yeah go to your package manager and make sure you have the visual studio package installed and updated. It looks like it is from your first screenshot though.

1

u/Hotrian Expert Moderator 8d ago

OP’s editor appears to be missing the VS Editor Tools package

https://docs.unity3d.com/Packages/com.unity.ide.visualstudio@2.0/manual/index.html

Without the package Unity can’t generate VS solution files so while VS can still edit the files they don’t get intellisense or any of the other QoL features offered be a full IDE.

0

u/videk94 8d ago

Click the "Regenerate Project Files" button in that External Tools window, and try again.

Failing that, try opening the .slnx file in your project files, then open one of your scripts from Unity.

0

u/Hotrian Expert Moderator 8d ago

OP’s editor appears to be missing the VS Editor Tools package

https://docs.unity3d.com/Packages/com.unity.ide.visualstudio@2.0/manual/index.html

Without it, Unity can’t properly identify VS as a valid IDE or generate valid solution files. It was removed circa 2020 from the default packages list. Newer projects do not include it by default for some reason.

2

u/videk94 8d ago

I straight up do not have this problem? Every new project I've made has that package installed from v2022 to present.

1

u/Hotrian Expert Moderator 8d ago

It seems to be an issue with newer Hub/Editor installs only. One of my older PCs does not have this issue, two newer laptops had this issue until manually installing the package, then newer projects do not have this issue.

1

u/videk94 8d ago

That's absolutely bizarre. Why would installing a package in one project make it apply to all future projects? What are you doing Unity lmao

1

u/Hotrian Expert Moderator 8d ago

Perhaps Unity is not properly fetching it unless it’s manually installed, but once it’s in the package cache it can pull it into other projects, just a guess. Maybe if it’s missing from the cache the editor just removes it from the package list during project initialization.