Visual studio 2022 is not auto-completing certain methods - visual-studio

I have recently downloaded visual studio 2022 for use in Unity and it was working correctly for a while, but today it has stopped auto-completing certain method names such as OnMouseButtonDown() and OnTriggerEnter2D(). Other methods such as Start() and Update() do work, but a majority of Unity specific methods are no longer auto completed. I've tried restarting visual studio code, restarting my computer and uninstalling and reinstalling visual studio code, but the error still persists. Any help would be greatly appreciated. Thanks.

This problem can cause various of reasons, even some IDE bug (which Visual Studio 2022 has a large number) but there is pretty common solution for this one
Firstly you'll have to make sure, that your Game development with Unity workload is checked
So
Open Visual Studio Installer and click Modify button across your version of Visual Studio.
Click on a Workloads panel and make sure that Game development with Unity workload is checked as shown on the image
Click Modify button at the bottom right corner.
Then you need to ensure, that desired version of Visual Studio is set as a External Script Editor inside Unity engine
Open Unity
Edit -> Preferences -> External Tools
And make sure that External Script Editor set as a current version of like so
Click on Regenerate project files button and try to always open your scripts directly from Unity
Restart Unity after those steps

Related

Visual studio intellisense is not auto completing unity monobehaviour methods

I had visual studio 2019(don't know which version) and intellisense was working fine. It was suggesting every unity functions(like start, update, onTriggerEnter, etc.) as well as user defined functions.
Then there is info that Microsoft has removed its support for this version and i had to update it to 2019 v16.11.18. And now the intellisense which was previously working fine in every respect, stopped suggesting unity event functions or monobehaviour functions only. Other keywords like gameobject, transform, GetComponent or user defined functions are being suggested without any problem. Its just some those crucial monobehaviour functions which got this problem.
I have double checked external tools settings in unity as well as tools for unity option in visual studio. My visual studio is not saying miscellaneous files on top left and i have nothing more to do.
Please help me..
I think it is now fixed. What i did is open visual studio installer and click repair on my visual studio. That's it.

Cannot find UnityEngine.InputSystem

I am currently working on a new unity project and to be honest i am new at this.
I need to use the InputSystem package but Visual studio does not recognize it.
This is the version of my VS. Microsoft Visual Studio Community 2019 Version 16.9.3 and the version of Unity is 2020.2.1
As you can see by the picture, my VS already knows that I am working in a Unity project.
So the first thing that I tried doing is to regenerate project files but it didnt work. I also selected my VS as my default external script editor.
This is my external tools.
I re-installed VS using unity hub but nothing happend.
Do you have any suggestions? I followed some tutorials I saw over the internet but I am still getting no positive results and to be honest, I am getting out of ideas.
Just tested out the package installation. I installed the package in a fresh, empty Unity project. Here are the steps that I went through which worked in my case:
Locate the Input System package in the Package Manager
Click install
A warning prompt will appear, click yes
Unity Editor should now get re-launched on it's own, wait for that to happen
If Visual Studio is open, close it
Open Visual studio - right click on the Assets folder and select Open C# project
UnityEngine.InputSystem namespace should now be available, if not, re-open Visual Studio one more time
Let me know if it works for you.
For me works when I install .NET and .NET Core and reboot the computer. (made this on Windows)
https://dotnet.microsoft.com/en-us/download
https://dotnet.microsoft.com/en-us/download/dotnet/3.1

VisualStudio not saving Startup Window

Since a few weeks I have had this infuriating problem.
Whenever I start VS it opens an empty environment.
I tried to change that in Options > Environment > Startup from "Empty environment" to "Start window". After pressing "OK" I restarted VS completely and reopened it. Again: a new empty environment opens.
After reinstalling VS several times now I gave up and want to know, if someone had a similar problem and knows a fix for this problem.
Visual Studio Enterprise 2019 (16.8.3)
Installed Workloads from VS-Installer:
ASP.NET and web development
Azure development
Python development
.NET desktop development
Desktop development with C++
Data storage and processing
.NET Core cross-platform development
Additional Extensions:
JetBrains ReSharper 2020.2.4
Visual Studio Tools for Tizen
*all the extensions are up-to-date
After MONTHS I finally found a solution. I basically tried to uninstall all extensions and discovered that this issue only occurs while ReSharper is installed. I didn't find anything regarding this on the internet, therefore I searched all of the options and I finally found the issue!
If you have the same issue and have ReSharper installed (currently 2020.3.3) open Visual Studio and go to Extensions/ReSharper/Options. A new window will pop up. Then navigate to Environment/Performance Guide and under the group Visual Studio preferences affecting performance you'll find the item Show empty environment at startup. Set it from Fix Silently to Ignore. Click Save and close this window.
Additionally, you have reset the specific Visual Studio option. Therefore open Tools/Options and navigate to Environment/Startup and set the On startup, open: to Start window. Click OK and restart Visual Studio to check if the Start Window now gets displayed correctly.

IntelliSense doesn't show Unity hints

So I'm new to Unity and I'm watching a few tutorials to learn the basics. Something that got my attention is that in the videos they have an autocomplete and while I've got it too, it gives too few options. For instance it doesn't show the Debug or any of its properties. It runs fine but it's really annoying.
I don't know if it's related but it also lacks some coloration. Like in the videos Debug is colored orange but mine is not colored differently from the rest.
Not sure about your VS version and Unity version, but please update them if possible. For example, you have VS2017 15.8 and Unity 2018.1, then please update them to VS2017 15.9.17 and Unity2018.3.8 or higher.
And it seems to be one similar issue like this report in DC. You can find details from Sebastien Lebreton for trouble-shooting the issue there.
Make sure:
Visual Studio is set as your external script editor in Unity (Edit/Preferences/External Tools)
Visual Studio plugin is installed in Unity (Help/About must display a message like Microsoft Visual Studio Tools for Unity is enabled at the bottom).
Then check that the extension is properly installed in Visual Studio (Help/About).
You can try:
backup your project
quit both VS and Unity
remove all generated sln/csproj
remove the hidden .vs folder in VS Solution folder
remove the Library folder
re-open the project with Unity
In Unity, use Assets/Open C# Project to open that in Visual Studio
In addition to Lance Li-MSFT's answer I happened to observe this: When you create a new script (for example with "Add Component" -> "New Script") and then try to open it directly, this can happen. So after you created your script, give unity a few seconds to compile and then open it. For scripts that are opened to early, I did not manage to fix them. They just won't show IntelliSens hints, otherwise they work perfectly normal.
Just spent some time solving this
(VS 2022 community, Unity 2020.3.30f).
It happens that by defaut in Unity
Edit \ Preferences \ External tools
"External script editor" is set to "Open file by extension".
And script does open in VS 2022, and script compiles in Unity after editing, but it does not create .vs folder with all project related stuff.
So intellisence just did not kick in to Unity.
But after I set "External script editor" to Visual Studio, it started to work
(hints and coloration).

set property 'system.windows.resourcedictionary.deferrablecontent' threw an exception

I'm running Visual Studio 2012, when I add a new File/Reference to a project the message box appears showing the error message
set property 'system.windows.resourcedictionary.deferrablecontent' threw an exception
I read an MSDN article suggesting to run the command devenv /resetuserdata on visual studio command prompt to resolve this problem, tried it but didn't work for me. In fact the command prompt shows the Unknown Error message.
Some addins cause this issue for me so have had to workaround it whenever it occurs:
In Vis studio -
Tools > Options > Environment > Add-in Security, uncheck 'Allow Add-in components to load', OK
Restart vis studio
The error shouldn't occur anymore, so go back to
Tools > Options > Environment > Add-in Security and re-check Allow Add-in components to load, OK
To be specific, I get this error when trying to add files to projects and manage Nuget Packages.
Update
I now make a point of opening
'Tools > Nuget package manager > Manage nuget packages for solution'
whenever I open up a new instance of Vis studio, before loading a solution, just to make sure the window loads properly
That way I know I won't get this issue.
In my case it was a style with the same key defined twice in a ResourceDictionary (WPF)
I have Windows azure tools for Microsoft VisulStudio 2013- v2.2 and Windows azure tools for Microsoft lightswitch VisulStudio 2013- v2.2.
I uninstall only Windows azure tools for microsoft lightswitch vs 2013 .
It's working fine...
I fixed it. The resolution was to remove the Windows Azure Tools for Visual Studio 2012 which I was not actually using, and the error went straight away.
In my case it was to first launch Visual Studio in safe mode. You can create a shortcut for visual studio with a target like this:
'"F:\Program Files\Visual Studio\VS2013\Common7\IDE\devenv.exe" -safemode'
Once launched in safe mode, you can remove the problematic extension via the Addin Manager. However, this wont work for some extensions, as the uninstall option might be disabled for certain extensions when running in safe mode, particularly if you have already uninstalled another extension in the same session.
In My case the problem was caused by Paradox Game engine, in which I had uninstalled it via 'Programs and Features' - which in return did not remove the extension which was originally installed via Nuget package. Uninstalling Paradox via "Programs And Features" left the extension itself still registered in Visual Studio, presumably causing a hidden NullReferenceException.
This issue can be caused by any extension that may have an error in it, or by extensions that were not properly uninstalled.
Also, see this article...
The mentioned issue can be resolved by simply restart the Visual Studio. :P
Also seem to be able to get around this by closing the project and vis studio instance, re-opening, then when the start page/open project screen appears selecting Tools > Extensions and Updates..., then pressing Close
Now open the project and the error doesn't get thrown when trying add files or manage nuget packages, weird.
Just annoying you have to remember to open Extensions and Updates each time...
Other wise make sure given Resourcedictionary.xaml path is correct or not
I had to remove Xamarin from Add/Remove Programs in Control panel and restart Visual studio to fix this.
I had this problem with My Devexpress Project in VS 2015
What finally worked for me was.
Close my solution,
Close Visual Studio,
Open Visual Studio,
Create a New dummy project,
Add a form to it,
Close and save the new project,
Reopen original project and all was ok.
for everyone else who are working in silverlight sdk environment with windows phone8 sdk.
The versions of sliverlight which are compatible with visual studio versions -
vs2012- sliverlight sdk 4
vs2013- silverlight sdk 5
I was integrating in vs2013 and as soon as I updated it with silverlight sdk 5, The errors went away.
In my case it was the Line Endings: you can have different formatting and by copy pasting some code one file got a different Line Ending. It was enough to File > Save As and then click the little arrow next to the save button.
Then click on save with encoding and choose the one you are using in all other files.
See Andrew Truckle's answer.
I hope this helps

Resources