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

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

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

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


当前回答

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

其他回答

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

这个页面帮助我解决了这个问题。

修复Unity与Visual Studio断开连接的问题

在Unity Editor中,选择Edit > Preferences菜单。

在左侧选择External Tools选项卡。

对于外部脚本编辑器,请选择现有的Visual Studio版本。

单击“重新生成文件”

你做了

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

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

两个备选方案:

解决1

@singleton为我指明了这个方向。而不是在Visual Studio中更改目标,你应该在Unity中更改它,因为项目是自动生成的。

首先删除自动生成的Visual Studio文件: .csproj .user . sln

然后从Unity进入PlayerSettings,在“其他设置”下将“脚本运行时版本”从稳定3.5更改为实验性4.6。

然而,这并没有解决我的问题。

修复2

我注意到所有与Unity相关的代码都带有黄色警告。检查您的错误日志,看看情况是否如此。特别是查看是否得到以下错误:getreferenceNearestTargetframeworkTask

如果是,试试: 再次启动Visual Studio安装程序。

在Build Tools 2017中,单击“修改”,

确保勾选“Nuget目标和构建任务”。如果你点击通用Windows平台开发,这应该会被勾选。

上面的一种方法对我有用,我刚刚找到了这个问题的解决方案, 1. 首先,转到项目目录并删除.sln文件 2. 第二,进入unity,双击你的脚本。那么Visual Studio将会打开一个错误,

然后单击确定并关闭Visual Studio编辑器。 最后,关闭你的Windows防御器,然后转到你的项目目录,会有一个。csproj文件。只需双击并从Visual Studio编辑器中打开它,打开assets文件夹中的scripts文件夹,然后打开脚本,自动完成将会非常好地工作。