0

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.

What I see in VS

  • The coloring thing is gonna be a user set thingy imo – Menyus Nov 04 '19 at 20:37
  • Did you open this script by double clicking in Unity? Or did you open it separately from the file system? – Erik Overflow Nov 04 '19 at 22:07
  • @ErikOverflow double clicked it in Unity – Στυλιανός Βασιλείου Nov 04 '19 at 23:13
  • Top left of the image, see where it says "Miscellaneous Files"? Visual Studio doesn't reload the solution when Unity changes it. Best I've found is to either restart VS or reload the solution, which you have to do *every time* you create a new code file in the Unity editor. – Draco18s no longer trusts SE Nov 04 '19 at 23:50
  • this is a common issue one MS really broke about this time last year and then fixed but it still randomly happens, if it never works then it hasnt connected vs and unity if it usually works a restart of vs usually fixes it but it mainly seemed to be triggered by making new scripts (https://stackoverflow.com/questions/55337121/visual-studio-loses-ability-to-attach-to-unity-why) – BugFinder Nov 05 '19 at 09:36

3 Answers3

0

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

LoLance
  • 25,666
  • 1
  • 39
  • 73
  • Thanks, it worked. it seemed I didn't see that it needed a special thing for Unity while installing it – Στυλιανός Βασιλείου Nov 06 '19 at 23:24
  • @ΣτυλιανόςΒασιλείου Hi friend, if my answer helps to resolve your issue, please consider [marking it as answer](https://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work/5235#5235) to indicate this issue is answered. And if you've used own workaround to resolve it, you can also add it as [self-answer](https://stackoverflow.com/help/self-answer). – LoLance Nov 07 '19 at 09:32
0

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.

nrs
  • 371
  • 1
  • 9
0

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