DLL中的Unity c#脚本

时间:2013-08-07 03:25:55

标签: c# dll unity3d

在Unity 4.1项目中,我希望在DLL中拥有所有C#脚本。 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 个答案:

答案 0 :(得分:3)

确保您正在针对.NET framework 3.5或更低版本编译DLL。

To change the targeted .NET Framework version in an existing project:

  1. 打开要更改的项目。
  2. 解决方案资源管理器工具栏中,选择属性按钮。
  3. 您还可以在解决方案资源管理器中选择项目节点,打开上下文菜单(通过右键单击节点),然后选择属性
  4. 您应该会在应用标签上看到设置。如果不这样做,请选择它。
  5. 目标框架下拉列表中,选择所需的 .NET Framework 版本。然后点击确定按钮

答案 1 :(得分:0)

解决

我正在使用Visual Studio 2012编译DLL,包括运行时和编辑器。 针对.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

相关问题