[c#] Unity Scripts edited in Visual studio don't provide autocomplete

When I want to edit C# Unity scripts, they open in Visual Studio. It is supposed to provide auto complete for all Unity related code, but it doesn't work.

Here you can see the missing functionality:

Video of missing autocomplete feature

As seen, the transform object does not open the autocomplete menu.

Unity version: 5.5.2f1
Visual studio 2015
Visual Studio Tools for Unity is installed

This question is related to c# visual-studio unity3d intellisense

The answer is


My autocomplete also didn't work because Visual Studio Tools for Unity wasn't installed. So, after you install that, delete the auto generated Visual Studio files. Others said that you open file again and the problem is solved but it's not.

The trick is: instead of normally double-clicking the file, you need to open the C# file from Unity by right click and then "Open C# Project".


Unload and reload the project, in Visual Studio:

  • right click your project in Solution Explorer
  • select Unload Project
  • select Reload Project

Fixed!

I found this solution to work the best (easiest), having run into the problem multiple times.

Source: https://alexdunn.org/2017/04/26/xamarin-tips-fixing-the-highlighting-drop-in-your-xamarin-android-projects/


What worked me is that I copied all the code inside the broken class and removed that file. Then, I opened an empty file with the same name and pasted back.

Result: beautiful syntax highlights came back!


This page helped me fix the issue.

Fix for Unity disconnected from Visual Studio

enter image description here

In the Unity Editor, select the Edit > Preferences menu..

Select the External Tools tab on the left.

Select unity version from drop down list on the right

Click regenerate Files

You Done


In my case, correct .net version was not installed on my PC. I install the .net 3.5 on my pc and that worked for me.


Before restarting and/or re-installing VS, First try opening any other of your projects to see if Intellisence works, if it does, then issue probably lies with your current project. First, most probable victim would be the NUGET packages with pending updates. To Fix this,

  1. Right click on references
  2. Proceed to Manage NUGET Packages Under NUGET Packages
  3. proceed to updates Install Updates and recheck Intellisence

one of the above methods are worked for me and I just found a solution to this problem,
1. First, go to the project directory and delete .sln file
2. Second, go to unity and double click your script. Then Visual Studio will be open with an error, enter image description here

  1. Then click ok and close Visual Studio editor.
  2. Finally, turn off your Windows Defender and then go to your project directory and there will be .csproj file. Just double click and open this from your Visual Studio editor and open the scripts folder inside the assets folder and open the scripts and autocompletion will be working perfectly fine.

  • Go to Options on the Tools menu and then select Documents in the Environment node. (If Documents does not appear in the list, select Show all settings in the Options dialog box.)
  • Put a tick on "Miscellaneous files in Solution Explorer" and Click OK. (This option displays the "Miscellaneous Files" node in Solution Explorer. Miscellaneous files are files that are not associated with a project or solution but can appear in Solution Explorer for your convenience if you tick this option.)
  • Locate your file in the Solution Explorer under "Miscellaneous Files". Then drag and drop your file to where it should belong and voila! This will copy the file to where you drop it. You may now safely delete the older file under Miscellaneous Files folder if you wish to do so

Credits: https://stackoverflow.com/a/47662523/10471480


In case Scripts folder is not visible:

  • Click on "Show all files" in Solution Explorer
  • Locate the Scripts folder.
  • Right Click on Scripts and select "Include in Project"

Try pressing Ctrl + Alt + Space (which toggles between suggestion and standard completion modes)


Try this,

  1. In Unity Editor Go to Menu, Click on Edit -> Preferences -> External Tools -> External Script Editor. Set it to Visual Studio (your installed version of VS).

  2. Now in Menubar go to Edit -> Project Settings -> Player Settings -> Other Settings -> Under Configuration -> Check API Compatibility Level -> Change it to your installed .Net version. In my case I set it to .Net 4.x

Now if Visual Studio is running already go to Visual Studio, it will ask to reload project. Reload the project. Check if it works, if not close Visual Studio. Now Open cs file from Unity Editor, and now it should work.


Try with combination: Ctrl + Alt + Space


None of the above solutions worked for me. However I opened the ProjectName.CSPROJ file and manually added the new file and it worked like charm


Two Alternative Options:

Fix 1

@singleton pointed me in this direction. Instead of changing the target in Visual Studio you should change it in Unity since the project is auto-generated.

First delete the auto generated Visual Studio files: .csproj .user .sln

Then from within Unity go to PlayerSettings and under 'Other Settings' change the 'Scripting Runtime Version' from Stable 3.5 to Experimental 4.6.

However, that didn't fix it for me.

Fix 2

I noticed all of the references to Unity related code was marked with a yellow warning. Check your error logs and see if this is the case. In particular see if you get the following error: getreferenceNearestTargetframeworkTask

If so try: Start Visual Studio Installer again.

On the Build Tools 2017, click Modify,

Ensure that "Nuget targets and build tasks" are ticked. This should become ticked if you click on Universal Windows Platform development.


Keep in mind that if you are using the ReSharper tool, it will override the IntelliSense and show it's own. To change that, on VS, go to Extensions -> ReSharper -> Options -> IntelliSense -> General then choose Visual Studio and not ReSharper.


i found my solution by creating the .cs file from visual studio itself instead of unity editor

  • right click on project folder in solution explorer
  • add > new item
  • type "unity" on the search field on the top right
  • select "CSharp MonoBehaviour"
  • name your script on the bottom and click Add

Another possible fix:

  1. In the project window, click on the Assets folder
  2. Right click, and Create -> C# Script
  3. Double click that, and wait.

For some reason, this work.


For Windows or macOS:

Download/Install the Visual Studio IDE (with Unity Tools)

When installing, make sure you include installation of

Game development with Unity

enter image description here

Then using Unity (you can double click one of your C# files), open a new C# project and the Visual Studio IDE should open with your new project structure.

enter image description here

From there, you should be able to see what you are looking for.

For example:

enter image description here

enter image description here

For Linux (suggestion):

Try Monodevelop - Additional Information, it provides code completion/hints.


I hit the same issues today using Visual Studio 2017 15.4.5 with Unity 2017.

I was able to fix the issue by right clicking on the project in Visual Studio and changing the target framework from 3.5 to 4.5.

Hope this helps anyone else in a similar scenario.


I solved to install the same version of .NET on WIN that was configured in my Unity project. (Player Settings)


Update 2020 with Visual Studio Community 2019 and Unity 2019.3:

  1. Open Visual Studio Installer as Administrator, select to modify your current installation and add "Game development for Unity"

  2. If you add a new c# script in Unity now, and open it (automatically) with Visual Studio, it is not described as "Miscellaneous" at the top of the window but with "Assembly-CSharp", and the autocomplete works.


If you have done all of the above and still isn't working , just try this: Note: you should have updated VS. Screenshot from visual studio

Goto Unity > edit> preference >External tools> external script editor. Unity screenshot Somehow for me I had not selected "visual studio" for external script editor and it was not working. As soon as i selected this and doubled clicked on c# file from unity it started working.

I hope it helps you too.


I tried all of these but ended up finding out that I needed to right-click the solution in Solution Explorer and add existing items and find the C# assembly file in Window's Explorer. There seem to be a bazillion different problems that give you this error, this is likely the most simple solution. If you double click on your script from unity, it does not seem to drag the assembly along.


The issue I faced was that the C# Project was targeting a different .NET Framework (4.7.2), whereas the Unity project had a different target (.NET 3.5).

I fixed this by changing the target in Unity as-

File -> Build Settings -> Player Settings -> Other Settings -> API Compatibility Level : Set it to the .NET version you already have installed (Check your .NET Version here). In my case, it was 4.x

After this, Visual Studio worked perfectly and autocorrect was fixed too.


  1. Select project in Visual Studio
  2. Click "Refresh" button

enter image description here


For some odd reason, the "Game development with Unity" tool can become disabled in Visual Studio.

To fix this..

  1. Open Visual Studio
  2. Go to Extensions ? "Manage Extensions" ? Installed
  3. Find "Visual Studio 2019 Tools for Unity"
  4. If it is disabled, enable it
  5. Restart VS

Credit to Yuli Levtov's answer on another Thread


I found an another way to fix this issue in a more convenient manner:

  1. Select the broken file in Solution Explorer.
  2. Open its Properties.
  3. Switch field "Build Action" from "Compile" to "None".
  4. Then switch it back to "Compile".

This will kill the synchronization between Unity and Visual Studio somehow.

The next time Visual Studio will reload the project, it will prompt a warning. Just click on "Discard".


Examples related to c#

How can I convert this one line of ActionScript to C#? Microsoft Advertising SDK doesn't deliverer ads How to use a global array in C#? How to correctly write async method? C# - insert values from file into two arrays Uploading into folder in FTP? Are these methods thread safe? dotnet ef not found in .NET Core 3 HTTP Error 500.30 - ANCM In-Process Start Failure Best way to "push" into C# array

Examples related to visual-studio

VS 2017 Git Local Commit DB.lock error on every commit How to remove an unpushed outgoing commit in Visual Studio? How to download Visual Studio Community Edition 2015 (not 2017) Cannot open include file: 'stdio.h' - Visual Studio Community 2017 - C++ Error How to fix the error "Windows SDK version 8.1" was not found? Visual Studio Code pylint: Unable to import 'protorpc' Open the terminal in visual studio? Is Visual Studio Community a 30 day trial? How can I run NUnit tests in Visual Studio 2017? Visual Studio 2017: Display method references

Examples related to unity3d

Unity Scripts edited in Visual studio don't provide autocomplete not finding android sdk (Unity) Serialize and Deserialize Json and Json Array in Unity How to make the script wait/sleep in a simple way in unity Unity 2d jumping script How to prepare a Unity project for git? "A namespace cannot directly contain members such as fields or methods" How to use Git for Unity3D source control? How to prevent colliders from passing through each other? What Language is Used To Develop Using Unity

Examples related to intellisense

Unity Scripts edited in Visual studio don't provide autocomplete Visual Studio displaying errors even if projects build Why does intellisense and code suggestion stop working when Visual Studio is open? Cannot use Server.MapPath Intellisense and code suggestion not working in Visual Studio 2012 Ultimate RC Visual Studio C# IntelliSense not automatically displaying Eclipse Intellisense? Why is SQL Server 2008 Management Studio Intellisense not working?