I have a Little problem with scripts. When I'm writing C# scripts for Unity with Visual studio it seems like I`m working in notepad, there are no autocompletion (correct?) and I must write it very slowly.
Please, watch the video. At start is the normal situation (from tutorial), second part shows my problem.
For example, the transform
class does not show suggestion or autocomplete.
Image with Problem:
Unity version: 5.5.2f1
Visual studio 2015
Visual Studio Tools for Unity is installed
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.
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.
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-
After this, Visual Studio worked perfectly and autocorrect was fixed too.
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".
Credits: https://stackoverflow.com/a/47662523/10471480
In case Scripts folder is not visible:
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