Asked  7 Months ago    Answers:  5   Viewed   97 times

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



There is no auto-completion because the script says "Miscellaneous Files" instead of the of the name of the Project. Take a look at the image below that came from the video in your question:

enter image description here

The "Miscellaneous Files" message can happen for many reasons:

  1. It can happen when you open your Unity C# file from another folder instead of opening it from Unity Editor.

  2. This can also happen because Unity crashed while Visual Studio is still open therefore corrupting some files.

  3. It can happen because Unity was closed then re-opened but is no longer connected to Visual Studio. When Visual Studio is opened you get "Miscellaneous Files" and no auto-completion.

  4. This can happen when Visual Studio Tools for unity is not installed.

  5. When you create a script from Unity then quickly open it before Unity finish processing it or before the round icon animation stuff finish animating.

Most of the times, restarting Unity and Visual Studio should fix this.

I can't tell which one is causing the problem but I will cover the most likely solution to fix this.

Fix Part 1:

  1. Download and Install Visual Studio Tools for unity from this link. Do this while Unity and Visual Studio are both closed.

  2. From Unity Editor, go to Edit ? Preferences... ? External Tools. On the External Script Editor drop down menu, change that to Visual Studio 2015.

    enter image description here

Fix Part 2:

If newly created C# files are coming up as Miscellaneous then follow the instruction below:

  1. From Visual Studio, go to Tools ? Options... ? Tools for Unity ? Miscellaneous. Under Show connectivity icon, set it to true then restart Visual Studio.

    enter image description here

  2. When you re-start, connection icon should now be available in Visual Studio. Click it then choose the Unity instance to connect to. The red 'x' icon should now turn into a brown checkmark icon. Now, when you create a new C# file in Unity, it should open without saying Miscellaneous.

    enter image description here

Fix Part 3:

Still not fixed?

Re-import project then open C# Project.

  1. Close Visual Studio.

  2. From Unity, re-import project by going to Assets ? Reimport All.

    enter image description here

  3. Now, open the project in Visual Studio by going to Assets ? Open C# Project. This will reload the project and fix possible solution file problems.

    enter image description here

Fix Part 4:

Still not fixed?

Fix each C# file individually.

  1. Click on Show All Files icon.

    enter image description here

  2. Select the script that doesn't do auto-complete then right-click and select Include In Project.

    enter image description here

Fix Part 5:

Not fixed yet?

Credit goes to chrisvarnz for this particular solution which seems to have worked for multiple people.

  1. Close Visual Studio

  2. Go your project directory and delete all the generated Visual Studio files.

    These are the files extensions to delete:

    • .csproj
    • .user
    • .sln


    Let's say that the name of your Project is called Target_Shoot, these are what the files to delete should look like:

    • Target_Shoot.csproj
    • Target_Shoot.Editor.csproj
    • Target_Shoot.Editor.csproj.user
    • Target_Shoot.Player.csproj
    • Target_Shoot.Player.csproj.user
    • Target_Shoot.sln

    Do not delete anything else.

  3. Double click on the script again from Unity which should generate new Visual Studio file then open Visual Studio. This may solve your problem.

Fix Part 6:

If not working, check if you are having this error:

The "GetReferenceNearestTargetFrameworkTask" task was not found

  1. Install Nuget PackageManager from here.

  2. Restart Visual Visual.

See this answer for more information.

Tuesday, June 1, 2021
answered 7 Months ago

It sounds like you're wanting snippets. You can add them yourself, or you can install an extension from the marketplace that will come with a number of popular snippets baked in.

You may be interested in changing the settings below as well, controlling how tab works and whether or not snippets appear first in the suggestions.

  • editor.snippetSuggestions
  • editor.tabCompletion

Open settings with ?, on mac, or Ctrl+ on Windows. Then search for the setting and click the edit icon next to the result.

Wednesday, March 31, 2021
answered 9 Months ago

enter image description here

In prose, in case you can't see the above image:

Open Tools > Options > Text Editor. If you're only having this issue with one language, find that language; if it's for everything, click "All Languages". Right at the top, there'll be a few options labeled "Auto list members", "Hide advanced members", and "Parameter information". Make sure all of those are enabled (though the second may be disabled; if so, ignore it).

Thursday, June 17, 2021
answered 6 Months ago

Finally had to create a brand new solution and add the projects from the older solution to the newly created one. Not sure what the problem was, but this helped.

Tuesday, August 24, 2021
answered 4 Months ago

I believe what you are looking for is the Import Symbol Creation with Re#. I use this all the time when accessing members that are not part of the current using statements. In essence, Re# will look through all your referenced assemblies and see if anything matches and then provide a list of those possible matches and import if needed.

Import Symbol Completion (formerly known as Type Name Completion) displays all types that match a given prefix regardless of what namespace they belong to (as opposed to Symbol Completion, which only completes names of currently visible types). Import Symbol Completion automatically inserts appropriate namespace import directives to the current file if a selected type has not been imported previously. It also works after dot with extension methods and puts necessary using directives.

The default Re# key mapping is Ctrl+Alt+space.

I'm not sure if I updated my mappings, but I have to use: Shift+Alt+space

Wednesday, November 3, 2021
answered 1 Month ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :