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

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

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

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


当前回答

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

其他回答

你安装这个?

安装Visual Studio和Unity 下载Visual Studio安装程序,如果已经安装,则打开它。 对于所需版本的Visual Studio,选择“修改”(如果已经安装)或“安装”(对于新安装)。 选择workload选项卡,然后选择Game development with Unity workload。 如果Unity尚未安装,请在安装程序的可选部分中选择Unity Hub复选框。 选择Modify或Install完成安装。

在Unity中,编辑>首选项>外部工具 单击“重新生成项目文件”。

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

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

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

在左侧选择External Tools选项卡。

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

单击“重新生成文件”

你做了

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

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

2020年更新Visual Studio Community 2019和Unity 2019.3:

以管理员身份打开Visual Studio安装程序,选择修改当前安装并添加“Game development for Unity” 如果你现在在Unity中添加一个新的c#脚本,然后用Visual Studio(自动)打开它,它在窗口顶部的描述不是“Miscellaneous”,而是“Assembly-CSharp”,并且自动完成工作。