Visual Studio与Unity不对应 [英] Visual Studio doesn't correspond with Unity
问题描述
所以,这发生在几天前.我在Unity(最新版本)和Visual Studio 2017中开发了一个项目.我不得不更换计算机/机器,因此我将文件夹与该项目一起存档,以便将来打开它.
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.
我迁移到的计算机/计算机具有去年版本的Unity和VS2017.我更新了所有内容,在Unity中打开了该项目-一切正常.但是,当我尝试打开Visual Studio更改代码时-首先,所有代码行都带有红色下划线,并且存在许多错误,其次,Unity代码没有自动补全功能.
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.
首先,我尝试重新安装所有可能的东西.我删除了Unity和VS并重新安装了它们.没有改变. 其次,我尝试重新安装一些VS版本,而2017和2019均无法正常工作.我什至尝试在Unity首选项中更改为VSCode,但没有运气.
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?
推荐答案
我过去也遇到过类似的问题.对我有用的东西:
I had similar issues in the past. What worked for me:
1)确保Unity和VS已关闭
1) Make sure Unity and VS are closed
2)从统一项目文件夹(* .csproj)和项目文件(.sln)中删除所有Visual Studio文件
2) Remove all the visual studio files from your unity project folder (*.csproj) as well as the project file (.sln)
3)删除Library/Temp文件夹
3) remove the Library/Temp folders
4)在Unity中启动项目
4) Start your project in Unity
5)双击打开一个.cs或.js文件.
5) Open a .cs or .js file from within unity by double clicking it.
由于要重新创建所有VS项目文件,Visual Studio的打开时间会稍长一些,但是希望您不会再出现无效的编译器错误,并且自动补全功能再次起作用.
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.
希望这会有所帮助
这篇关于Visual Studio与Unity不对应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!