IntelliSense doesn't show Unity hints - visual-studio

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).

Related

Visual studio 2022 is not auto-completing certain methods

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

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

Console Application not found on visual studio 2015

I just download visual studio community to my pc. When i opened the vs-2015 and create new Console application project. i can't find it any where under the c# we installed templates or any templates.
Thinking about to uninstall and install again but this not the first time i uninstall and install this, i did installed and uninstall few time but still can't find the web Console Application template.
Thank you.
I had the same problem and found the solution on another site. Here are the steps that need to be performed:
Open a Visual Studio command window with admin privileges. This can be done from Windows search after clicking on the Windows button (or Start button - depending on the OS) located in the lower left corner. Make sure that you don't have any Visual Studio project open before proceeding.
Type in prompt in the search box and select "Developer Command Prompt". Right click on this and select run with admin privileges.
In the command window Enter:
cd C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE
In the command window then enter:
devenv /installvstemplates
This worked for me and I was able to create a new console project after this.
With my version of VS 2015 community edition, upon install there was a Console Application (Package) template available, which I mistakenly thought was a Console Application template. This is not the case. It is a web console application project and I only discovered this after trying to access the File and Directory classes in System.IO from my code. The compiler kept on complaining:
Error CS0234 The type or namespace name 'Directory' does not exist in the namespace 'System.IO' (are you missing an assembly reference?)
MyProject.DNX Core 5.0 ...
It still complained after putting in a reference to System.IO and even after changing the offending line of code to:
string DataPath = System.IO.Directory.GetCurrentDirectory();
A big clue here is the reference to DNX Core 5.0, which is an optimized run-time for ASP apps. It was at that point that I discovered that the Console Application (Package) template was also listed under the New Project window Templates / Visual C# / Web.
So, For others that may happen to find this post and think you are using a standard Console Application template, but have errors like "CS0234 The type or namespace "name" does not exist in the namespace..." then you could be using a Console Application (Package) template - which is probably not what you want and should be replaced by a regular Console Application. If you don't see it in the New Project window under Templates / Visual C#, then you should follow the steps above to install it.
EDIT
This is what my New Project window looks like after I performed the steps above:
Comparing this window with yours above, it appears to be somewhat different. Notice that "New Project" on my window is centered and for yours it is not. Also, at the bottom of the window yours has only Name, Location and Solution name, while my window adds a fourth item called Solution.
So, first thing, try clicking on Visual C# located in the left pane of your New Project window to see the templates available. Post that snapshot here. This can be done by selecting edit.
If you still don't see the Console Application template, then perhaps you downloaded a different version of Visual Studio 2015 than I did. So, here is the screen that pops up after selecting Help / About Microsoft Visual Studio on my system:
Compare this screen with yours and post a snapshot of your screen here. Also, what operating system are you using?
Thanks again Bob for your time to explained it to me, i am really appreciate that, I uninstalled and installed again from this link enter link description here, On my machine i have Visual Studio 2015(this one works) and Blend for Visual Studio 2015 is still missing template but i don't care it anymore if it work or not because i will use the one that works which is the Visual Studio 2015.

Debugging in Unity (C#) + Visual Studio Code Work on OS X?

I really like the idea of working with Visual Studio, C# and Unity on OS X.
Has anyone made debugging with C# in Unity work with Visual Studio Code on OS X?
Yes it works absolutely fine. Unity is C#, JavaScript or Boo. So, you don't need .NET for it. Unity uses Mono runtime. So, an existing VS project can be opened in Unity for Mac OS X.
EDIT
Here is a link that helps you to attach a debugger to the VS endpoint.
http://www.yunspace.com/2015/01/19/integrating-visualstudio-with-unity3d-on-mac-using-vstools/
You can try VS Tools for Unity too.
http://unityvs.com
UPDATE
There is this awesome Unity Plugin by dotBunny that solves the problem and integrates Code with Unity tools.
Hi the solution is https://github.com/dotBunny/VSCode This plugin works on both MacOS and Windows and gives you the following capabilities:
•An option to enable VS Code integration (Editor –> Assets –> Enable Integration), this updates your solution files and (more importantly) keeps them in sync. This also sets the preferred external tool editor in the Unity preferences.
*Note, the old “Sync MonoDevelop” option is now gone in the Unity editor from V5.2
•It writes out the necessary (and sometimes hard to find) VS Code configuration files, including the ability to hide “non-code” files in the editor (hides things like .sln, .csproj and the ever present unity .meta files)
There are a couple of other settings in there to help speed up the integration.
•Automatically launches VS Code direct to your project folder, EVERY-TIME. no longer do you have to worry about keeping that window open, or switching around if you work on multiple projects
One thing to be aware of, once you enable the VSCode integration, changing your preferred code editor in the External Tools preferences will have no effect as the plugin takes over opening code files. If you want to use another editor, you’ll have to disable the integration first.
These are just the main highlights as there are more features in there as well.
Currently you need to download the plugin files from GitHub
An existing Visual Studio solution can be build and debugged with Visual Studio Code on the Mac with Mono. You have to use the launch.json and tasks.json files.
I described it on my blog: Compile and Debug
To build Unity in Visual Studio Code, you can hook up Mono xbuild compiler as a task runner, so you don't even have to leave IDE to have errors and warnings.
See https://twitter.com/_eppz/status/846859856787259392 for more.
It's a little unstable. But it's possible from recent VSC version.
1) Install this VSC Unity plugin-in.
https://github.com/dotBunny/VSCode/
2) Follow these commands. (Step 1, 2 and 3)
https://code.visualstudio.com/Docs/runtimes/unity
3) After you complete the settings, launch the VSC using Unity menu.
Assets/Open C# Project in Code
4) Play the Unity project.
You can see the debug port number on the unity console.
And the project's launch.json file will be renewed automatically.
To open launch.json, click option icons.
the file exists in this folder.
.vscode/launch.json
sample.
{
"version":"0.1.0",
"configurations":[
{
"name":"Unity",
"type":"mono",
"address":"localhost",
"port":56621
}
]
}
5) Start debug in VSC debug tab.
That's it. Hope this help.
Update, 2016 - the petition was popular enough that some VS Code extensions have been written for it: https://marketplace.visualstudio.com/search?term=unity&target=VSCode&sortBy=Relevance
Petition for it on the Visual Studio UserVoice page: http://visualstudio.uservoice.com/forums/293070-visual-studio-code/suggestions/7752702-unity-integration
[Feb 2017] It is now possible to do this without the dotBunny plugin.
i.e. Support is built into Unity natively.
Just to repeat, you don't need to fiddle with Unity, just VSCode.
Instructions here
Instructions are incomplete though, and I didn't take screenshots (please do!), but basically what I did was:
(...and please improve these instructions as you go, I'm working from memory...)
I deleted/renamed my .vscode/Launch.json file, as per the link.
Double-click on some file to bring up the project in VSCode (maybe first make sure that in Unity's settings you have selected VSCode as your default code editor)
clicking the bug icon then the cogwheel, as per the link.
I had to install that vscode-unity-debug plugin in VSCode, just filtering the search with 'unity' found it.
I then had to press the green 'play' triangle.
I set a breakpoint in my code.
Now over to unity and press play, and the breakpoint gets hit.
The Unity Debugger for Visual Studio Code is working, but doesn't work well enough when doing any kind of serious work for now. I really hope they will improve it in the future as I prefer VS Code over VS.
Current problems I encountered
-Sometimes I cannot step in a function, the debugger will hang until you detach
-no local variable, you have to watch everything
-some more complex variable have no support, so you can't see what is inside
-A bit overall unstable with unexpected behaviours.
What I love about it,
Attaching & Detaching is a breeze. Just press a button, allowing to attach and detach quickly as needed. e.g. At the beginning of the program I work on, there will be an bunch of exception. I can detach and attach quickly to skip the exceptions.
The problems with it are too constraining as it currently stands, I had to go back to the classic Visual Studio.

VS2013 Build "Does not support previewing"

Every time I try to build my solution in VS2013, nothing builds, no errors - But in the status bar it says: "This item does not support previewing"
I googled around a bit but have come up empty.
But if I right click on each project and select build it works fine.
Any ideas?
Perhaps this message is totally unrelated... Post hoc ergo propter hoc
Steps to reproduce on my machine:
Right Click any project in solution: select build
Status bar displays Build successful
Right click solution select build
Status bar displays : "This item does not support previewing"
Perhaps it isnt related, but it sure does appear to be.
I was able to fix this... Somehow nothing was selected to build in the solution configuration. I right clicked on the solution, went to properties and then selected COnfiguration Properties and clicked the Build box for all the projects...
I have no idea how they became unchecked, only thing I can think of is a co-worker was trolling me.....
I've had this problem (i.e. debug not starting, and no error message) with Visual Studio 2015 in the following two cases:
after loading a solution that had previously been built with Visual Studio 2010
and also after using the "save as" function in Visual Studio 2015 to update a solution that had been started with Visual Studio 2010 (using Save as updates the solution file and sets the active Visual Studio version to 14 - i.e. VS 2015).
In both cases, deleting the bin and obj directories under the startup project fixed the problem. It's also worth closing visual studio and making sure that there are no {yourprojectname}.vshost.exe processes still running - if there are then kill them before running visual studio again. On that note, if you have multiple versions of visual studio on your machine, you should also check that you don't have the same solution open in the other version of visual studio at the same time (I've done that one myself).
One of the comments here suggests disabling the "enable visual studio hosted process" option. Don't do that if you can at all avoid it: you'll lose lots of debugging functionality (particularly in the area of being able to edit code while your solution is running).
Hope that helps someone out there.
Solution for VS2015
"this item does not support previewing" vs2015 (Visual Studio 2015/2016)
Step 1. Go to Control Panel -> Programs and Features
Step 2. Uninstall all: Windows Software Development Kit - Windows 10.0.10586.15 (maybe you have diff ver)
Step 3. Download new latest Windows Software Development Kit
https://go.microsoft.com/fwlink/p/?LinkId=619296
Install & Create new project, Done!
Dclick on MainPage.xaml and you will see Loading designer...
1: Add below lines in App.conf
<specFlow>
<unitTestProvider name="MSTest"></unitTestProvider>
</specFlow>
2: add a reference to Microsoft.VisualStudio.QualityTestTools.UnitTestFramework.dll
right click on your project and select: Add Reference
3: add using Microsoft.VisualStudio.TestTools.UnitTesting; in Step Defination
4: goto feature file and run it. This is what solve my problem on vs2013
I faced same issue with .aspx file. I just right click on the .aspx file and select open with (HTML Editor). You can choose any form the list.
I have come across the same issue for me, I have opened a project in VS 2010 and then when I open the same in VS 2015 then his error has occurred.
Solution:
By Closing the VS2010 project solution fixed the issue.

Resources