当我想编辑c# Unity脚本时,它们会在Visual Studio中打开。它应该为所有与Unity相关的代码提供自动补全,但它不起作用。
在这里你可以看到缺失的功能:
可以看到,转换对象没有打开自动完成菜单。
Unity版本:5.5.2f1 Visual studio 2015 安装Visual Studio Tools for Unity
当我想编辑c# Unity脚本时,它们会在Visual Studio中打开。它应该为所有与Unity相关的代码提供自动补全,但它不起作用。
在这里你可以看到缺失的功能:
可以看到,转换对象没有打开自动完成菜单。
Unity版本:5.5.2f1 Visual studio 2015 安装Visual Studio Tools for Unity
当前回答
我尝试了所有这些方法,但最终发现我需要在解决方案资源管理器中右键单击解决方案,并添加现有项目,并在windows的资源管理器中找到c#程序集文件。似乎有无数不同的问题会给你这个错误,这可能是最简单的解决方案。如果你在unity中双击脚本,它似乎不会拖动程序集。
其他回答
我今天使用Visual Studio 2017 15.4.5和Unity 2017遇到了同样的问题。
我可以通过在Visual Studio中右键单击项目并将目标框架从3.5更改为4.5来解决这个问题。
希望这能帮助到其他有类似情况的人。
试试这个,
在Unity编辑器的菜单,点击编辑->首选项->外部工具->外部脚本编辑器。将其设置为Visual Studio(您安装的VS版本)。 现在在菜单栏选择编辑->项目设置->播放器设置->其他设置->在配置下->检查API兼容性级别->将其更改为您安装的。net版本。在我的例子中,我将它设置为.Net 4.x
现在如果Visual Studio正在运行,转到Visual Studio,它会要求重新加载项目。重新加载项目。检查它是否工作,如果不能关闭Visual Studio。现在从Unity Editor中打开cs文件,现在它应该工作了。
Go to Options on the Tools menu and then select Documents in the Environment node. (If Documents does not appear in the list, select Show all settings in the Options dialog box.) Put a tick on "Miscellaneous files in Solution Explorer" and Click OK. (This option displays the "Miscellaneous Files" node in Solution Explorer. Miscellaneous files are files that are not associated with a project or solution but can appear in Solution Explorer for your convenience if you tick this option.) Locate your file in the Solution Explorer under "Miscellaneous Files". Then drag and drop your file to where it should belong and voila! This will copy the file to where you drop it. You may now safely delete the older file under Miscellaneous Files folder if you wish to do so
学分:https://stackoverflow.com/a/47662523/10471480
如果脚本文件夹不可见:
在解决方案资源管理器中单击“显示所有文件” 找到Scripts文件夹。 右键单击脚本,选择“包含在项目中”
我面临的问题是c#项目的目标是不同的。net框架(4.7.2),而Unity项目的目标是不同的(4.7.2)。NET 3.5)。
我通过将Unity中的目标更改为-来解决这个问题
文件->构建设置->播放器设置->其他设置-> API 兼容性级别:将其设置为您已有的.NET版本 安装(检查你的。net版本在这里)。在我的例子中,它是4.x
在此之后,Visual Studio工作得很好,自动更正也被修复了。
从Unity选择编辑选项,然后~>首选项…~>外部工具,然后打开内置包。我尝试了所有的解决方案,只有这一个帮助我,我打开它的机会!