Auto completion doesn't work for me

When Nathan is able to press ctrl + period, he can implement the interface, use the appropriate namespace, if even sees Instantiate and can have it auto complete for him. For some reason, those are not options that I have so I have been manually typing everything in, but I would like to try figureing out why my Visual Studio Code does not seem to be as helpful.

I am using the extensions mentioned at the beginning of the mobile development course, but I do get a problem loading "project Assembly-CSharp.csproj. I can share the long list of what I am receiving, but I wanted to share this first to see if this is a known problem people run into and know a fix

Visual Studio Code has a habit of changing often, making true diagnosis quite difficult.

Here’s a link with one of the more common issues Syntax highlighting/ Code suggestion not working - Unity Courses / Ask - GameDev.tv

Also, Visual Studio Code has a new plugin that we should be using. Details are here: Syntax highlighting/ Code suggestion not working - Unity Courses / Ask - GameDev.tv

It does concern me, though that there is a problem loading Assembly-CSharp.csproj. Make sure that in Editor/Preferences/External tools, the code Editor is set to VS Code, and then click on Regenerate Project files.

This thread might also help:

Thank you for the suggestions!

Not sure if @Brian_Trotter you meant to send the same link twice or if you were wanting to share a different thread. I tried .Net 7 and that didnt work for me.

After installing Net Framework 4.7.1, I got it working on one project, but as soon as I switched over to a different project I started a couple months ago, I don’t see any errors, but the auto completion wasn’t coming up. I am not sure what the differences are between the projects, so I am not sure what I should be looking for, any ideas?

That should have been a different link for the second one:
Announcing the Unity extension for Visual Studio Code - Visual Studio Blog

This looks like a cool extension! I tried getting it to work, but maybe I didn’t follow the instructions correctly because this didn’t work for me in my current project, which seems like strange behavior to me

I haven’t done it (I use JetBrains Rider). It’s something I should do to test VS Codeand get better at troubleshooting, but Editor/Preference is a cross project setting, and I don’t want to destroy my current work flow.

You mentioned it working properly in one project, but not working in another. That leads me to believe it might be a Project settings issue…

Go into Project Settings/Player and scroll to the last section (Other Settings). Look for the API Compatablity Level. If you go with Net Standard 2.1 instead of .Net Framework, I think you might get better results

I took a look at my settings in the location you mentioned and the API compatibility level is set to .NET standard 2.0. The only other option I have is .NET 4.x - does this mean I should look into updating Unity itself from 2021.1.12f1?

Possibly… or switching to Visual Studio Community, which just plain works.

How hard is it to switch to Visual Studio Community?

Just a matter of installing it, and selecting it as the editor in Editor | Preferences | External Tools.

After installing it seems like this is working! I was nervous about trying something new since I am used to VS Code, so I will need to give it some time. You mentioned using JetBrains Rider - how is that?

JetBrains Rider is a paid application (it starts around $15 a month, and each year it drops – for example, I now pay about $10.00 a month because I’ve been using it for years and years).

It does have a slightly different look and feel from the Visual Studio versions (although you can set things up to have the Visual Studio hotkeys and some of the look. It’s a 64 bit application, which is part of what drove me to it. A large project can quickly overwhelm the 4 Gig maximum address space in a 32 Gig application, especially if you also use Unreal Engine. That being said, Visual Studio Community 2022 is (FINALLY) a 64 bit application.

Out of the box, analyzes not just your code, but also goes through your scenes and prefabs to find instances of your class and useages of your code. It gives suggestions to streamline your code (and automatically supports older as well as newer versions of Unity, so for example, in Unity 2022, it will look at a line like this:

public List<string> someStrings = new List<string>();

and suggest using the newer syntax

public List<string> someStrings = new();

And of course, it won’t make that suggestion at all if you’re in Unity 2020 or 21 because those versions of c# don’t support that construction).

It’s very good at catching codesmells in general.

They also offer a plugin for Visual Studio Community that allows you to use much of their code analysys tools within VSC. I found, personally, it just made more sense to make the switch wholesale to JetBrains Rider, and I’ve never really looked back.

Either Community or Rider are head and shoulders better code editors (though they do have a larger footprint on your hard drive) than Visual Studio Code. We use Code in our lectures because unlike Community, it is available with the same look and feel on Linux, Mac, and Windows, and unlike Rider, it’s free. Since Code is an open source community driven tool (for many languages, not just C# and Unity’s flavor of C#), though, keeping it working with Unity becomes more and more of a challenge as time goes by.

1 Like

Awesome! Thank you for the detailed explanation! If I find myself heading towards full-time, this will definitely be something I invest in! Thanks again for the help with my Unity project!

I find it invaluable. Worth every penny.

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms