Visual Studio doesn't correspond with Unity

走远了吗. 提交于 2019-12-10 22:14:13

问题


So, this happened a couple of days ago. I worked on a project in Unity (latest version) and Visual Studio 2017. I had to change computers/machines, so I archived the folder with the project in order to open it in the future.

The computer/machine I migrated to had last year's version of Unity and VS 2017. I updated everything, opened the project in Unity - everything was working fine. However, when I try to open Visual Studio to change the code - firstly, all lines of code are underlined red and there are many mistakes, secondly, there is no autocompletion for Unity code.

First of all, I tried to reinstall everything I could. I deleted both Unity and VS and installed them again. Nothing changed. Second of all, I tried reinstalling some VS versions, and both 2017 and 2019 didn't work. I even tried to change to the VSCode in Unity preferences, but no luck.

So, the question is how to fix?


回答1:


I had similar issues in the past. What worked for me:

1) Make sure Unity and VS are closed

2) Remove all the visual studio files from your unity project folder (*.csproj) as well as the project file (.sln)

3) remove the Library/Temp folders

4) Start your project in Unity

5) Open a .cs or .js file from within unity by double clicking it.

Visual studio will take slightly longer to open since it's going to re-create all the VS project files, but hopefully you get no more invalid compiler errors, and autocompletion works again.

Hope this helps



来源:https://stackoverflow.com/questions/56697516/visual-studio-doesnt-correspond-with-unity

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!