Intellisense no longer works - c#

I've been using Visual Studio Code with unity for around 2 months now without problems, but since last week I suddenly get no more Intellisense (no code completion for C# or Unity). I don't recall changing anything and I have no idea why it suddenly stopped working.
I was using Unity 5.4 with this recommended plugin to enable VSCode integration when Intellisense stopped working.
I've already reinstalled VSCode and updated Unity to version 5.5. Unity 5.5 has built in support for VSCode, so I've removed the editor plugin from my project. I can indeed open Unity scripts in VSCode without the plugin now, but I'm still not getting any code completion.
I saw there was an update for the C# VSCode extension today, but updating that didn't help either. I've attached a screenshot of the log during this update:
As you can see there's no flame icon and the code completion is missing. The Omnisharp log is either empty or completely missing (not sure why this behaviour is not always the same).
Does anyone have any idea what I can do to fix this? Thanks.

So in my experience, whenever something weird like this happens in Visual Studio, the first thing you should do is kill all instances of VS and restart. For good measure, you could even reboot your computer, though this is often not necessary. If that still doesn't help, the next best thing is to reset your VS settings which can be done by going to
Tools -> Import and Export Settings -> Reset All Settings
A backup of the current settings are recommended, but not required.

After checking that VS is the default editor in Preferences, open your Unity project with Explorer. See if you can find a .sln file, and open it with VS. Then, go to your solution manger inside VS and try and open any of your Unity project's scripts from the manager. After doing this, your Intellisense should be working.
This worked for me when I had a similar issue side time ago.

Related

VSCode does not show Unity Intellisense, is there any fix for it?

I have been trying to setup Unity and VSCode for a couple days now and I believe I have tried everything under the sun to get intellisense to work. To be more clear of the problem, intellisense does not appear to show up when typing anything Unity related. Apart from looking for a fix to intellisense, is there anyway to check what version of mono, vscode, and omnisharp are installed? If extra info is needed, I can provide.
I am using an iMac 2011 running macOS Monterey, if more info needed just ask and I will provide.
I am truly stumped and any help would be greatly appreciated.
I have downloaded both mono, omnisharp and all packages for .csproj. I have also made sure VSCode is set to my external script editor in Unity as well as setting API configurability is set to .Net Framework (I read on here that might help). So far the only problem I can assume is messing up intellisense is the omnisharp, I am unaware if omnisharp is properly download as I keep getting offered to download it when reloading or opening VSCode. I do however, believe I fixed the omnisharp as I recently download the latest version for it. I am honestly starting to believe that I just turned off intellisense without realizing it.
I will try to the best of my abilities to describe in depth of what I did in order to help any future unfortunate coders.
Set VSCode to External Script Editor in unity. (Go To Unity > Preferences > External Tools then select what IDE you are using.
While in External Tools, check all boxes under .csproj files and then regenerate project files.
Close Unity and open VSCode and then go to settings (Code > Preferences > Settings. Search for "Omnisharp:UseModernNet" uncheck that setting and if prompted, install any Omnisharp builds.
In setting still, search "Omnisharp: Path" and type in "Latest", you will probably be prompted to install a new Omnisharp again, install it.
After that, close and reopen VSCode through the dock or application folder. If it IntelliSense doesn't work, I suggest download mono if not already download. Again if not already download, you must download .Net SDK files.
I apologize if the answer is a bit sloppy, I am baffled that it works, after submitting the question, all I had to do was quit and reopen VSCode from the dock and it somehow just started working. Good luck to anyone with this problem, I hoped this helped. If anymore info is need or any questions feel free to message me and I'll help the best I can.

VSCode intellisense with Unity not working

Note this is on my desktop;
I started a little side project in unity several weeks ago, and intellisense was working just fine. It had been working since I switched my unity code editor to VSCode long before I started this project. I went to work on it a little today and it was just gone. The only suggestions it gave me were words it had already seen, i.e. C# methods I'd used like AddLast from a LinkedList or a few method names from my own classes I'd referenced.
Every suggestion was either marked with the little "abc" tag instead of the icons indicating whether they were properties or methods, or the suggestion was a method related to unity with a missing icon.
This is especially weird, because I have a "duplicate" project on my laptop that I carry with me on campus so I can jot ideas down the second I get them. Everything is the same between both devices, the same project settings, the same preferences, the same VSC environments, the same extensions, settings, preferences, and packages.
I get intellisense on my laptop.
I've been reading threads for hours, and nothing has worked from any of them! Fresh install of C# dev kit, eliminating sln/csproj files and regenerating them from preferences, changing .net compatibility level, pointing omnisharp "in the right direction," and hours of watching unity, vscode, and my desktop shut down and reboot just to name a few.
Thanks in advance for any helpful pointers, proof I belong in a mental ward, or both!
I found the issue
Modern C# extension updates with vs code don't support unity.
See here:
Following the issue's heed, I turned off modern net with omnisharp while using extension version 1.25. Then, I updated my vs code package to the latest version (1.2.5 as of writing) and regenerated all project files from preferences (having vs code set as the designated editor).
All credit to sleepysheepy for pointing me in this direction
Does it help if you go to the C# extension and roll back to version v1.24.4, and then reload VSCode?
Pardon me if you already said you tried that! That's what did the trick when IntelliSense stopped working for me recently.

AutoComplete does not work when I use VS code with Unity

I work with unity and the VS code autocomplete does not complete many unity objects and more..
I have 2 extensions on my VS:
1.C# for Visual Studio Code (powered by OmniSharp).
2.Unity Code Snippets.
I'm using windows 10 and I looking for answers on the web for weeks, I tried to play with the settings, open new projects, reinstall VS CODE and nothing happen.
also I saw that it's happen mostly to people with an old version of Unity but it's not my case..
I work with unity version 2021.1.15f1 personal and VSCODE 1.59.1
This is a picture that illustrates the situation
Apologies if you've tried everything there already, but following the instructions at this link have helped me get auto-complete for Unity set up in VS Code when I got started: https://code.visualstudio.com/docs/other/unity
One key aspect that I had missed originally was the Unity Script Editor set up section. IntelliSense only starts working after you have opened a script via the Unity Editor rather than straight in VS Code. It generates an Assembly-CSharp.csproj file at the root which is necessary for enabling the functionality.
Make sure that Visual Studio Code is selected as the default "External Script Editor" in your Unity preferences.
To do that in Unity, go to Edit->Preferences and then select "Visual Studio Code" as your preferred external script editor. Restart VSC afterwards.

Unity 2019.2.* - Invisible/empty errors after trying to build

In short, for some reason I can not figure out, two empty errors appear in my log. These persist after clearing, on restart and occur in every project, both existing and new. Un- and re-installing Unity seem to have no effect whatsoever.
This issue started appearing for me in Unity 2019.2.1 and persists even after updating to the most recent 2019.2.14f1. Because they are errors, they prevent me from running or building the project which means I am completely stuck and can not use Unity until I find a way to fix this. I am using Windows 10.
I have already submitted this issue to Unity, but I think it is an issue with my installation, so I don't know if they'll be able to help me.
The issue appeared in one project and seemed to be contained to that one project until I attempted to build another project. The moment I try to build a project, the issue appears and will persist no matter what I do. Even if a project is completely empty and brand new, the moment I attempt to build the project, the errors appear and the project becomes "cursed" with them.
Something that might be the cause, but might also be a symptom, is that scripts will indicate that they can not find UnityEngine. Is there any way to manually install those libraries?
Even after manually uninstalling Unity, Visual Studio and removing all references to Unity from AppData, then installing the most recent versions of Unity and Visual Studio, the issue persists.
I have not been able to test an affected project on a different computer, but I will update this question if I do.
If Unity does get back to me with a solution I'll post that.
Edit:
The true cause of the issue was that for whatever reason, Unity could not find Roslyn. Hence why scripts were unable to compile, which resulted in the Unity Editor itself being affected.
I've added the solution to this issue as an answer to this question.
This issue has been solved with a response from the Unity team!
This is their solution:
Please try the following steps to fix the issue:
1. Close any open Unity Editors
2. Go to "C:\Program Files\Unity\Hub\Editor\(Your Unity version)\Editor\Data\Tools\RoslynScripts"
3. Edit "unity_csc.bat" (You might have to run Notepad as an administrator to be able to save it)
4. Replace the line that says "%APPLICATION_CONTENTS%\Tools\Roslyn\csc" /shared % with the following: "C:\Program Files\Unity\Hub\Editor\(Your Unity version)\Editor\Data\Tools\Roslyn\csc.exe" /shared %
Leaving it here for any future Google searches.

The breakpoint will not currently be hit. No symbols have been loaded for this document in Unity

I am trying to debug a coroutine in Unity using VS2017.
When I attach VS to Unity and set a breakpoint inside the IEnumerator method I get the error "Breakpoint will not be hit"
It is discussed in depth here:
How do I remedy the "The breakpoint will not currently be hit. No symbols have been loaded for this document." warning?
However none of those answers worked for me.
Do you know how to set a breakpoint inside an IEnumerator in VS2017?
This is known bug in Unity. Here is how to fix this:
1.Go to File --> Build Settings... then select your platform.
2.Click on Player Settings --> Other Settings and change the API Compatibility Level to .NET 2.0.
If it is already set to .NET 2.0, change it to .NET 2.0 Subset then back to .NET 2.0.
3.Close and re-open Visual Studio. From Visual Studio, go to Build --> Clean Solution then Build --> Rebuild Solution.
Try debugging again and it should work.
If the steps above did not work, Go your Project's Library folder then deltete it. Restart both Unity and Visual Studio.
I spent enough time and found the solution. Go to Build-> Configuration Manager and change Active Solution Configuration to Debug.
In my case, this happened when this script was not attached to anything in the scene, therefore, the breakpoint would never be hit... something unexpected from somebody who works in C++. This is a nice side effect, though.
In my case it was because I was using "Attach to process" instead of "Attach to Unity ...". The latter was not available, because the Unity addon for VS failed to install.
So, i had these too
The unity doesnt know which script tool you are using..
In Unity, do Edit -> Preferences.
In the Preferences window that opened, choose the External Tools tab.
Click on the External Script Editor dropdown.
Click on Browse.
Select Visual Studio 2017 if not already selected
GoodLuck (;
(:
I had the same issue. Following steps solved mine.
Navigate to build->configuration manager.
check for project configuration. If it is set to production, change this value to debug.
I found a solution (workaround).
You need to add the attribute [InitializeOnLoad] to the class.

Categories

Resources