当我想编辑c# Unity脚本时,它们会在Visual Studio中打开。它应该为所有与Unity相关的代码提供自动补全,但它不起作用。

在这里你可以看到缺失的功能:

可以看到,转换对象没有打开自动完成菜单。

Unity版本:5.5.2f1 Visual studio 2015 安装Visual Studio Tools for Unity


当前回答

我的自动补全也不能工作,因为没有安装Visual Studio Tools for Unity。因此,在安装之后,删除自动生成的Visual Studio文件。其他人说你再次打开文件,问题就解决了,但事实并非如此。

诀窍在于:你不需要双击文件,而是需要在Unity中右键单击“open c# Project”来打开c#文件。

其他回答

嗯,也许你可以把我的指南看作是一种可选的方法。我在使用Unity 2020和Visual Studio Code 1.26时遇到了这个问题 为了解决这个问题,我采取了以下步骤:

在Visual Studio中的c#插件中 从https://www.monodevelop.com/download安装Mono 让我们看看Mono是安装在你的Mac的这个命令。例如,在我的Mac中,它是/Library/Frameworks/Mono.framework/Versions/Current 回到c#插件,打开它的设置,并在设置中更改下面的设置。插件的Json:

    "omnisharp.monoPath": "/Library/Frameworks/Mono.framework/Versions/Current",
    "omnisharp.useGlobalMono": "always"

开始....

使我成功的是,我复制了坏类中的所有代码并删除了该文件。 然后,我打开一个具有相同名称的空文件并粘贴回来。

结果:漂亮的语法亮点回来了!

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文件夹。 右键单击脚本,选择“包含在项目中”

在重新启动和/或重新安装VS之前,首先尝试打开任何其他项目,看看智能是否工作,如果是这样,那么问题可能在于您当前的项目。首先,最有可能的受害者是带有挂起更新的NUGET包。为了解决这个问题,

右键单击引用 继续管理NUGET包下的NUGET包 继续更新安装更新和重新检查智能

尝试按Ctrl + Alt + Space(可以在建议补全模式和标准补全模式之间切换)