Unity Scripts edited in Visual studio don't provide autocomplete

前端 未结 26 1490
半阙折子戏
半阙折子戏 2020-11-22 10:02

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 c

相关标签:
26条回答
  • 2020-11-22 10:21

    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

    0 讨论(0)
  • 2020-11-22 10:22

    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.

    0 讨论(0)
  • 2020-11-22 10:23

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

    Goto Unity > edit> preference >External tools> external script editor. 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.

    0 讨论(0)
  • 2020-11-22 10:23

    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.

    0 讨论(0)
  • 2020-11-22 10:24

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

    0 讨论(0)
  • 2020-11-22 10:25

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

    0 讨论(0)
提交回复
热议问题