在Unity 4.1项目中,我希望将所有C#脚本都放在DLL中 . Unity创建一个Visual Studio项目,我能够正确编译代码 . 编译生成DLL但Unity不识别所有类,只识别那些继承MonoBehaviour的类 . 所有课程都是公开的,Unity是专业的 . 如何让Unity“看到”所有课程?
我尝试使用Mono 2.8进行编译,它构建了DLL . 所有类似乎都存在,但没有任何作用,我得到这些错误:
ApplicationException: Unable to find a suitable compiler
UnityEditor.Scripting.ScriptCompilers.CreateCompilerInstance (MonoIsland island, Boolean buildingForEditor, BuildTarget targetPlatform) (at
C:/BuildAgent/work/7535de4ca26c26ac/Editor/Mono/Scripting/ScriptCompilers.cs:99)
和
Failed to create compiler instance
2 回答
解决了
我'm using Visual Studio 2012 for compiling the DLL' s,运行时和编辑器 . 针对.NET 3.5 . 这篇文章给了我很多帮助:http://forum.unity3d.com/threads/148078-Reducing-script-compile-time-or-a-better-workflow-to-reduce-excessive-recompiling?p=1026639&viewfull=1#post1026639
确保您正在针对.NET framework 3.5或更低版本编译DLL .
To change the targeted .NET Framework version in an existing project:
打开要更改的项目 .
在 Solution Explorer 工具栏中,选择 Properties 按钮 .
您还可以在 Solution Explorer 中选择项目节点,打开上下文菜单(通过右键单击节点),然后选择 Properties .
您应该在 Application 选项卡上看到设置 . 如果不这样做,请选择它 .
在 Target Framework 下拉列表中,选择所需的 .NET Framework 版本 . 然后单击 OK button .