I should always close the Visual Studio and reopen it, so that the error * CS0246: The type or namespace name could not be found (are you missing a using directive or an assembly reference?) disappears.
IntelliSense also stops working. But unity itself seems to have no problem with that, so I can start my game and there are no errors in the unity’s console.
The issue appeared after I made a Visual Studio Update to the Version 17.11.1
The problem comes also if I open 2 unity projects at the same time and add a script to one of them. Then the references get lost in both projects.
I’d like to up this post, I have pretty much the same issue and it’s slowly driving me mad. Apologies for not knowing the terminologies and if I don’t explain things clearly.
I’m using 2022.3.35 and every time I create a script from within Unity, I lose all Intellisense in Visual Studio 2022; more than that actually, it’s like the IDE is not able to understand anything coming from libraries (like Unity.Entities, Unity.Burst, etc.), it only recognizes basic C# elements (like floats, struct, classes…). But unlike OP it does NOT throw any errors, it just… doesn’t seem to mind? When I hover anything written in white or greyed out, it doesn’t tell me anything. It doesn’t care.
My best solution is, just like @olgaschubert , to close Visual Studio and re-open it. I’ve tried regenerating the project files from within Unity Preferences: this only works when I change the checkbox selection (i.e. uncheck/check some boxes before clicking on “Regenerate project files”). Otherwise, nothing happens, nothing seems to get recompiled. I’ve looked for an option to reload the solution/project from within Visual Studio, without having to restart it, but found nothing.
Thanks for reading
EDIT: I just found out that renaming a script from inside Visual Studio with “Ctrl R, R” also breaks everything in the same manner.
it’s hard to say because I just got back to it a few weeks ago, but yes I did update to 17.11.1 at the time. I’m gonna try to downgrade it to a previous version and see if that works.
EDIT: It looks like one cannot downgrade their version of Visual Studio if one is not an Enterprise or Professional customer .
EDIT 2: @olgaschubert , when trying to install an earlier version, I found out there is an update available, 17.11.3. I’ve reinstalled VS with this version, and my problem seems to be gone. You could try to update your app and see if it works for you too (if it doesn’t, maybe try instead to uninstall then install it again?)
Hi @CanardCoinCoin, I’ve reinstalled VS, but the problem is still there
The issue comes also if I open 2 unity projects at the same time and add a script to one of projects. Than the references get lost in both projects.
I also reinstall unity and also installed different unity versions, but nothing happend.
I have the same problem as described above. And it only happens if I open a NEW script from Unity in VS. Opening “old” scripts aka those that have already been opened in VS at least once is fine.
I am on the latest VS 2022 (17.11.3).
This problem/bug was never present in 2019 version of VS and until now it also wasnt in the older 2022 VS version(s).
Latest VS versions started making problems for me too, not that drastic though. What I figured out is if you start VS from the command prompt (which Unity does) everything gets screwed up. Instead, close current VS instance and when in Unity try starting the VS from its own Open Dialog: find your project in the list and open it that way. It will “connect” with the Unity itself and everything will work better. It’s even confirmed with the VS team during my bug reporting
@iMobCoding Thank you for your comment! I’ve tried it out, but it didn’t work for me. Unfortunately as soon as I add a new script (even in VS itself) all the references goes away again So I need always to reopen VS.